
obj/user/num:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 9f 01 00 00       	call   8001d0 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800034 <num>:
int bol = 1;
int line = 0;

void
num(int f, char *s)
{
  800034:	55                   	push   %ebp
  800035:	89 e5                	mov    %esp,%ebp
  800037:	57                   	push   %edi
  800038:	56                   	push   %esi
  800039:	53                   	push   %ebx
  80003a:	83 ec 3c             	sub    $0x3c,%esp
  80003d:	8b 75 08             	mov    0x8(%ebp),%esi
  800040:	8b 7d 0c             	mov    0xc(%ebp),%edi
	long n;
	int r;
	char c;

	while ((n = read(f, &c, 1)) > 0) {
  800043:	8d 5d e7             	lea    -0x19(%ebp),%ebx
  800046:	e9 81 00 00 00       	jmp    8000cc <num+0x98>
		if (bol) {
  80004b:	83 3d 00 60 80 00 00 	cmpl   $0x0,0x806000
  800052:	74 27                	je     80007b <num+0x47>
			printf("%5d ", ++line);
  800054:	a1 78 60 80 00       	mov    0x806078,%eax
  800059:	83 c0 01             	add    $0x1,%eax
  80005c:	a3 78 60 80 00       	mov    %eax,0x806078
  800061:	89 44 24 04          	mov    %eax,0x4(%esp)
  800065:	c7 04 24 a0 2a 80 00 	movl   $0x802aa0,(%esp)
  80006c:	e8 b6 1b 00 00       	call   801c27 <printf>
			bol = 0;
  800071:	c7 05 00 60 80 00 00 	movl   $0x0,0x806000
  800078:	00 00 00 
		}
		if ((r = write(1, &c, 1)) != 1)
  80007b:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  800082:	00 
  800083:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800087:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  80008e:	e8 37 14 00 00       	call   8014ca <write>
  800093:	83 f8 01             	cmp    $0x1,%eax
  800096:	74 24                	je     8000bc <num+0x88>
			panic("write error copying %s: %e", s, r);
  800098:	89 44 24 10          	mov    %eax,0x10(%esp)
  80009c:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  8000a0:	c7 44 24 08 a5 2a 80 	movl   $0x802aa5,0x8(%esp)
  8000a7:	00 
  8000a8:	c7 44 24 04 13 00 00 	movl   $0x13,0x4(%esp)
  8000af:	00 
  8000b0:	c7 04 24 c0 2a 80 00 	movl   $0x802ac0,(%esp)
  8000b7:	e8 80 01 00 00       	call   80023c <_panic>
		if (c == '\n')
  8000bc:	80 7d e7 0a          	cmpb   $0xa,-0x19(%ebp)
  8000c0:	75 0a                	jne    8000cc <num+0x98>
			bol = 1;
  8000c2:	c7 05 00 60 80 00 01 	movl   $0x1,0x806000
  8000c9:	00 00 00 
{
	long n;
	int r;
	char c;

	while ((n = read(f, &c, 1)) > 0) {
  8000cc:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  8000d3:	00 
  8000d4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8000d8:	89 34 24             	mov    %esi,(%esp)
  8000db:	e8 73 14 00 00       	call   801553 <read>
  8000e0:	85 c0                	test   %eax,%eax
  8000e2:	0f 8f 63 ff ff ff    	jg     80004b <num+0x17>
		if ((r = write(1, &c, 1)) != 1)
			panic("write error copying %s: %e", s, r);
		if (c == '\n')
			bol = 1;
	}
	if (n < 0)
  8000e8:	85 c0                	test   %eax,%eax
  8000ea:	79 24                	jns    800110 <num+0xdc>
		panic("error reading %s: %e", s, n);
  8000ec:	89 44 24 10          	mov    %eax,0x10(%esp)
  8000f0:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  8000f4:	c7 44 24 08 cb 2a 80 	movl   $0x802acb,0x8(%esp)
  8000fb:	00 
  8000fc:	c7 44 24 04 18 00 00 	movl   $0x18,0x4(%esp)
  800103:	00 
  800104:	c7 04 24 c0 2a 80 00 	movl   $0x802ac0,(%esp)
  80010b:	e8 2c 01 00 00       	call   80023c <_panic>
}
  800110:	83 c4 3c             	add    $0x3c,%esp
  800113:	5b                   	pop    %ebx
  800114:	5e                   	pop    %esi
  800115:	5f                   	pop    %edi
  800116:	5d                   	pop    %ebp
  800117:	c3                   	ret    

00800118 <umain>:

void
umain(int argc, char **argv)
{
  800118:	55                   	push   %ebp
  800119:	89 e5                	mov    %esp,%ebp
  80011b:	57                   	push   %edi
  80011c:	56                   	push   %esi
  80011d:	53                   	push   %ebx
  80011e:	83 ec 3c             	sub    $0x3c,%esp
	int f, i;

	argv0 = "num";
  800121:	c7 05 80 60 80 00 e0 	movl   $0x802ae0,0x806080
  800128:	2a 80 00 
	if (argc == 1)
  80012b:	83 7d 08 01          	cmpl   $0x1,0x8(%ebp)
  80012f:	74 0b                	je     80013c <umain+0x24>
		num(0, "<stdin>");
	else
		for (i = 1; i < argc; i++) {
  800131:	83 7d 08 01          	cmpl   $0x1,0x8(%ebp)
  800135:	7f 1b                	jg     800152 <umain+0x3a>
  800137:	e9 86 00 00 00       	jmp    8001c2 <umain+0xaa>
{
	int f, i;

	argv0 = "num";
	if (argc == 1)
		num(0, "<stdin>");
  80013c:	c7 44 24 04 e4 2a 80 	movl   $0x802ae4,0x4(%esp)
  800143:	00 
  800144:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80014b:	e8 e4 fe ff ff       	call   800034 <num>
  800150:	eb 70                	jmp    8001c2 <umain+0xaa>
  800152:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800155:	83 c3 04             	add    $0x4,%ebx
  800158:	bf 01 00 00 00       	mov    $0x1,%edi
  80015d:	89 5d e4             	mov    %ebx,-0x1c(%ebp)
	else
		for (i = 1; i < argc; i++) {
			f = open(argv[i], O_RDONLY);
  800160:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  800167:	00 
  800168:	8b 03                	mov    (%ebx),%eax
  80016a:	89 04 24             	mov    %eax,(%esp)
  80016d:	e8 6a 19 00 00       	call   801adc <open>
  800172:	89 c6                	mov    %eax,%esi
			if (f < 0)
  800174:	85 c0                	test   %eax,%eax
  800176:	79 29                	jns    8001a1 <umain+0x89>
				panic("can't open %s: %e", argv[i], f);
  800178:	89 44 24 10          	mov    %eax,0x10(%esp)
  80017c:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80017f:	8b 02                	mov    (%edx),%eax
  800181:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800185:	c7 44 24 08 ec 2a 80 	movl   $0x802aec,0x8(%esp)
  80018c:	00 
  80018d:	c7 44 24 04 27 00 00 	movl   $0x27,0x4(%esp)
  800194:	00 
  800195:	c7 04 24 c0 2a 80 00 	movl   $0x802ac0,(%esp)
  80019c:	e8 9b 00 00 00       	call   80023c <_panic>
			else {
				num(f, argv[i]);
  8001a1:	8b 03                	mov    (%ebx),%eax
  8001a3:	89 44 24 04          	mov    %eax,0x4(%esp)
  8001a7:	89 34 24             	mov    %esi,(%esp)
  8001aa:	e8 85 fe ff ff       	call   800034 <num>
				close(f);
  8001af:	89 34 24             	mov    %esi,(%esp)
  8001b2:	e8 55 15 00 00       	call   80170c <close>

	argv0 = "num";
	if (argc == 1)
		num(0, "<stdin>");
	else
		for (i = 1; i < argc; i++) {
  8001b7:	83 c7 01             	add    $0x1,%edi
  8001ba:	83 c3 04             	add    $0x4,%ebx
  8001bd:	39 7d 08             	cmp    %edi,0x8(%ebp)
  8001c0:	7f 9b                	jg     80015d <umain+0x45>
			else {
				num(f, argv[i]);
				close(f);
			}
		}
	exit();
  8001c2:	e8 59 00 00 00       	call   800220 <exit>
}
  8001c7:	83 c4 3c             	add    $0x3c,%esp
  8001ca:	5b                   	pop    %ebx
  8001cb:	5e                   	pop    %esi
  8001cc:	5f                   	pop    %edi
  8001cd:	5d                   	pop    %ebp
  8001ce:	c3                   	ret    
	...

008001d0 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  8001d0:	55                   	push   %ebp
  8001d1:	89 e5                	mov    %esp,%ebp
  8001d3:	83 ec 18             	sub    $0x18,%esp
  8001d6:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8001d9:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8001dc:	8b 75 08             	mov    0x8(%ebp),%esi
  8001df:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  8001e2:	e8 d2 0f 00 00       	call   8011b9 <sys_getenvid>
	env = &envs [ENVX(envid)];
  8001e7:	25 ff 03 00 00       	and    $0x3ff,%eax
  8001ec:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8001ef:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8001f4:	a3 7c 60 80 00       	mov    %eax,0x80607c

	// save the name of the program so that panic() can use it
	if (argc > 0)
  8001f9:	85 f6                	test   %esi,%esi
  8001fb:	7e 07                	jle    800204 <libmain+0x34>
		binaryname = argv[0];
  8001fd:	8b 03                	mov    (%ebx),%eax
  8001ff:	a3 04 60 80 00       	mov    %eax,0x806004

	// call user main routine
	umain(argc, argv);
  800204:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800208:	89 34 24             	mov    %esi,(%esp)
  80020b:	e8 08 ff ff ff       	call   800118 <umain>

	// exit gracefully
	exit();
  800210:	e8 0b 00 00 00       	call   800220 <exit>
}
  800215:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800218:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80021b:	89 ec                	mov    %ebp,%esp
  80021d:	5d                   	pop    %ebp
  80021e:	c3                   	ret    
	...

00800220 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800220:	55                   	push   %ebp
  800221:	89 e5                	mov    %esp,%ebp
  800223:	83 ec 18             	sub    $0x18,%esp
	close_all();
  800226:	e8 5e 15 00 00       	call   801789 <close_all>
	sys_env_destroy(0);
  80022b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800232:	e8 b6 0f 00 00       	call   8011ed <sys_env_destroy>
}
  800237:	c9                   	leave  
  800238:	c3                   	ret    
  800239:	00 00                	add    %al,(%eax)
	...

0080023c <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  80023c:	55                   	push   %ebp
  80023d:	89 e5                	mov    %esp,%ebp
  80023f:	53                   	push   %ebx
  800240:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  800243:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  800246:	a1 80 60 80 00       	mov    0x806080,%eax
  80024b:	85 c0                	test   %eax,%eax
  80024d:	74 10                	je     80025f <_panic+0x23>
		cprintf("%s: ", argv0);
  80024f:	89 44 24 04          	mov    %eax,0x4(%esp)
  800253:	c7 04 24 15 2b 80 00 	movl   $0x802b15,(%esp)
  80025a:	e8 a2 00 00 00       	call   800301 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  80025f:	8b 45 0c             	mov    0xc(%ebp),%eax
  800262:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800266:	8b 45 08             	mov    0x8(%ebp),%eax
  800269:	89 44 24 08          	mov    %eax,0x8(%esp)
  80026d:	a1 04 60 80 00       	mov    0x806004,%eax
  800272:	89 44 24 04          	mov    %eax,0x4(%esp)
  800276:	c7 04 24 1a 2b 80 00 	movl   $0x802b1a,(%esp)
  80027d:	e8 7f 00 00 00       	call   800301 <cprintf>
	vcprintf(fmt, ap);
  800282:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800286:	8b 45 10             	mov    0x10(%ebp),%eax
  800289:	89 04 24             	mov    %eax,(%esp)
  80028c:	e8 0f 00 00 00       	call   8002a0 <vcprintf>
	cprintf("\n");
  800291:	c7 04 24 6e 2f 80 00 	movl   $0x802f6e,(%esp)
  800298:	e8 64 00 00 00       	call   800301 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  80029d:	cc                   	int3   
  80029e:	eb fd                	jmp    80029d <_panic+0x61>

008002a0 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  8002a0:	55                   	push   %ebp
  8002a1:	89 e5                	mov    %esp,%ebp
  8002a3:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  8002a9:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  8002b0:	00 00 00 
	b.cnt = 0;
  8002b3:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  8002ba:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  8002bd:	8b 45 0c             	mov    0xc(%ebp),%eax
  8002c0:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8002c4:	8b 45 08             	mov    0x8(%ebp),%eax
  8002c7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8002cb:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  8002d1:	89 44 24 04          	mov    %eax,0x4(%esp)
  8002d5:	c7 04 24 1b 03 80 00 	movl   $0x80031b,(%esp)
  8002dc:	e8 cc 01 00 00       	call   8004ad <vprintfmt>
	sys_cputs(b.buf, b.idx);
  8002e1:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  8002e7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8002eb:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  8002f1:	89 04 24             	mov    %eax,(%esp)
  8002f4:	e8 c7 0a 00 00       	call   800dc0 <sys_cputs>

	return b.cnt;
}
  8002f9:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  8002ff:	c9                   	leave  
  800300:	c3                   	ret    

00800301 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  800301:	55                   	push   %ebp
  800302:	89 e5                	mov    %esp,%ebp
  800304:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  800307:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  80030a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80030e:	8b 45 08             	mov    0x8(%ebp),%eax
  800311:	89 04 24             	mov    %eax,(%esp)
  800314:	e8 87 ff ff ff       	call   8002a0 <vcprintf>
	va_end(ap);

	return cnt;
}
  800319:	c9                   	leave  
  80031a:	c3                   	ret    

0080031b <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  80031b:	55                   	push   %ebp
  80031c:	89 e5                	mov    %esp,%ebp
  80031e:	53                   	push   %ebx
  80031f:	83 ec 14             	sub    $0x14,%esp
  800322:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  800325:	8b 03                	mov    (%ebx),%eax
  800327:	8b 55 08             	mov    0x8(%ebp),%edx
  80032a:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  80032e:	83 c0 01             	add    $0x1,%eax
  800331:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  800333:	3d ff 00 00 00       	cmp    $0xff,%eax
  800338:	75 19                	jne    800353 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  80033a:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800341:	00 
  800342:	8d 43 08             	lea    0x8(%ebx),%eax
  800345:	89 04 24             	mov    %eax,(%esp)
  800348:	e8 73 0a 00 00       	call   800dc0 <sys_cputs>
		b->idx = 0;
  80034d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  800353:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  800357:	83 c4 14             	add    $0x14,%esp
  80035a:	5b                   	pop    %ebx
  80035b:	5d                   	pop    %ebp
  80035c:	c3                   	ret    
  80035d:	00 00                	add    %al,(%eax)
	...

00800360 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800360:	55                   	push   %ebp
  800361:	89 e5                	mov    %esp,%ebp
  800363:	57                   	push   %edi
  800364:	56                   	push   %esi
  800365:	53                   	push   %ebx
  800366:	83 ec 4c             	sub    $0x4c,%esp
  800369:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  80036c:	89 d6                	mov    %edx,%esi
  80036e:	8b 45 08             	mov    0x8(%ebp),%eax
  800371:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800374:	8b 55 0c             	mov    0xc(%ebp),%edx
  800377:	89 55 e0             	mov    %edx,-0x20(%ebp)
  80037a:	8b 45 10             	mov    0x10(%ebp),%eax
  80037d:	8b 5d 14             	mov    0x14(%ebp),%ebx
  800380:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800383:	89 45 dc             	mov    %eax,-0x24(%ebp)
  800386:	b9 00 00 00 00       	mov    $0x0,%ecx
  80038b:	39 d1                	cmp    %edx,%ecx
  80038d:	72 15                	jb     8003a4 <printnum+0x44>
  80038f:	77 07                	ja     800398 <printnum+0x38>
  800391:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800394:	39 d0                	cmp    %edx,%eax
  800396:	76 0c                	jbe    8003a4 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  800398:	83 eb 01             	sub    $0x1,%ebx
  80039b:	85 db                	test   %ebx,%ebx
  80039d:	8d 76 00             	lea    0x0(%esi),%esi
  8003a0:	7f 61                	jg     800403 <printnum+0xa3>
  8003a2:	eb 70                	jmp    800414 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  8003a4:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8003a8:	83 eb 01             	sub    $0x1,%ebx
  8003ab:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8003af:	89 44 24 08          	mov    %eax,0x8(%esp)
  8003b3:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  8003b7:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  8003bb:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  8003be:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  8003c1:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8003c4:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8003c8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8003cf:	00 
  8003d0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8003d3:	89 04 24             	mov    %eax,(%esp)
  8003d6:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8003d9:	89 54 24 04          	mov    %edx,0x4(%esp)
  8003dd:	e8 4e 24 00 00       	call   802830 <__udivdi3>
  8003e2:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  8003e5:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  8003e8:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8003ec:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8003f0:	89 04 24             	mov    %eax,(%esp)
  8003f3:	89 54 24 04          	mov    %edx,0x4(%esp)
  8003f7:	89 f2                	mov    %esi,%edx
  8003f9:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8003fc:	e8 5f ff ff ff       	call   800360 <printnum>
  800401:	eb 11                	jmp    800414 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800403:	89 74 24 04          	mov    %esi,0x4(%esp)
  800407:	89 3c 24             	mov    %edi,(%esp)
  80040a:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  80040d:	83 eb 01             	sub    $0x1,%ebx
  800410:	85 db                	test   %ebx,%ebx
  800412:	7f ef                	jg     800403 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800414:	89 74 24 04          	mov    %esi,0x4(%esp)
  800418:	8b 74 24 04          	mov    0x4(%esp),%esi
  80041c:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80041f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800423:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80042a:	00 
  80042b:	8b 55 d8             	mov    -0x28(%ebp),%edx
  80042e:	89 14 24             	mov    %edx,(%esp)
  800431:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800434:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800438:	e8 23 25 00 00       	call   802960 <__umoddi3>
  80043d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800441:	0f be 80 36 2b 80 00 	movsbl 0x802b36(%eax),%eax
  800448:	89 04 24             	mov    %eax,(%esp)
  80044b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80044e:	83 c4 4c             	add    $0x4c,%esp
  800451:	5b                   	pop    %ebx
  800452:	5e                   	pop    %esi
  800453:	5f                   	pop    %edi
  800454:	5d                   	pop    %ebp
  800455:	c3                   	ret    

00800456 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  800456:	55                   	push   %ebp
  800457:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  800459:	83 fa 01             	cmp    $0x1,%edx
  80045c:	7e 0e                	jle    80046c <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  80045e:	8b 10                	mov    (%eax),%edx
  800460:	8d 4a 08             	lea    0x8(%edx),%ecx
  800463:	89 08                	mov    %ecx,(%eax)
  800465:	8b 02                	mov    (%edx),%eax
  800467:	8b 52 04             	mov    0x4(%edx),%edx
  80046a:	eb 22                	jmp    80048e <getuint+0x38>
	else if (lflag)
  80046c:	85 d2                	test   %edx,%edx
  80046e:	74 10                	je     800480 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  800470:	8b 10                	mov    (%eax),%edx
  800472:	8d 4a 04             	lea    0x4(%edx),%ecx
  800475:	89 08                	mov    %ecx,(%eax)
  800477:	8b 02                	mov    (%edx),%eax
  800479:	ba 00 00 00 00       	mov    $0x0,%edx
  80047e:	eb 0e                	jmp    80048e <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  800480:	8b 10                	mov    (%eax),%edx
  800482:	8d 4a 04             	lea    0x4(%edx),%ecx
  800485:	89 08                	mov    %ecx,(%eax)
  800487:	8b 02                	mov    (%edx),%eax
  800489:	ba 00 00 00 00       	mov    $0x0,%edx
}
  80048e:	5d                   	pop    %ebp
  80048f:	c3                   	ret    

00800490 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  800490:	55                   	push   %ebp
  800491:	89 e5                	mov    %esp,%ebp
  800493:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  800496:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  80049a:	8b 10                	mov    (%eax),%edx
  80049c:	3b 50 04             	cmp    0x4(%eax),%edx
  80049f:	73 0a                	jae    8004ab <sprintputch+0x1b>
		*b->buf++ = ch;
  8004a1:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8004a4:	88 0a                	mov    %cl,(%edx)
  8004a6:	83 c2 01             	add    $0x1,%edx
  8004a9:	89 10                	mov    %edx,(%eax)
}
  8004ab:	5d                   	pop    %ebp
  8004ac:	c3                   	ret    

008004ad <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  8004ad:	55                   	push   %ebp
  8004ae:	89 e5                	mov    %esp,%ebp
  8004b0:	57                   	push   %edi
  8004b1:	56                   	push   %esi
  8004b2:	53                   	push   %ebx
  8004b3:	83 ec 5c             	sub    $0x5c,%esp
  8004b6:	8b 7d 08             	mov    0x8(%ebp),%edi
  8004b9:	8b 75 0c             	mov    0xc(%ebp),%esi
  8004bc:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  8004bf:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  8004c6:	eb 11                	jmp    8004d9 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  8004c8:	85 c0                	test   %eax,%eax
  8004ca:	0f 84 f9 03 00 00    	je     8008c9 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  8004d0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8004d4:	89 04 24             	mov    %eax,(%esp)
  8004d7:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  8004d9:	0f b6 03             	movzbl (%ebx),%eax
  8004dc:	83 c3 01             	add    $0x1,%ebx
  8004df:	83 f8 25             	cmp    $0x25,%eax
  8004e2:	75 e4                	jne    8004c8 <vprintfmt+0x1b>
  8004e4:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  8004e8:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  8004ef:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  8004f6:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  8004fd:	b9 00 00 00 00       	mov    $0x0,%ecx
  800502:	eb 06                	jmp    80050a <vprintfmt+0x5d>
  800504:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  800508:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  80050a:	0f b6 13             	movzbl (%ebx),%edx
  80050d:	0f b6 c2             	movzbl %dl,%eax
  800510:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800513:	8d 43 01             	lea    0x1(%ebx),%eax
  800516:	83 ea 23             	sub    $0x23,%edx
  800519:	80 fa 55             	cmp    $0x55,%dl
  80051c:	0f 87 8a 03 00 00    	ja     8008ac <vprintfmt+0x3ff>
  800522:	0f b6 d2             	movzbl %dl,%edx
  800525:	ff 24 95 80 2c 80 00 	jmp    *0x802c80(,%edx,4)
  80052c:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800530:	eb d6                	jmp    800508 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800532:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800535:	83 ea 30             	sub    $0x30,%edx
  800538:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80053b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80053e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800541:	83 fb 09             	cmp    $0x9,%ebx
  800544:	77 54                	ja     80059a <vprintfmt+0xed>
  800546:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800549:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80054c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80054f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  800552:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  800556:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800559:	8d 5a d0             	lea    -0x30(%edx),%ebx
  80055c:	83 fb 09             	cmp    $0x9,%ebx
  80055f:	76 eb                	jbe    80054c <vprintfmt+0x9f>
  800561:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  800564:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800567:	eb 31                	jmp    80059a <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  800569:	8b 55 14             	mov    0x14(%ebp),%edx
  80056c:	8d 5a 04             	lea    0x4(%edx),%ebx
  80056f:	89 5d 14             	mov    %ebx,0x14(%ebp)
  800572:	8b 12                	mov    (%edx),%edx
  800574:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  800577:	eb 21                	jmp    80059a <vprintfmt+0xed>

		case '.':
			if (width < 0)
  800579:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80057d:	ba 00 00 00 00       	mov    $0x0,%edx
  800582:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  800586:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800589:	e9 7a ff ff ff       	jmp    800508 <vprintfmt+0x5b>
  80058e:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  800595:	e9 6e ff ff ff       	jmp    800508 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  80059a:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80059e:	0f 89 64 ff ff ff    	jns    800508 <vprintfmt+0x5b>
  8005a4:	8b 55 d0             	mov    -0x30(%ebp),%edx
  8005a7:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8005aa:	8b 55 c8             	mov    -0x38(%ebp),%edx
  8005ad:	89 55 d0             	mov    %edx,-0x30(%ebp)
  8005b0:	e9 53 ff ff ff       	jmp    800508 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  8005b5:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  8005b8:	e9 4b ff ff ff       	jmp    800508 <vprintfmt+0x5b>
  8005bd:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  8005c0:	8b 45 14             	mov    0x14(%ebp),%eax
  8005c3:	8d 50 04             	lea    0x4(%eax),%edx
  8005c6:	89 55 14             	mov    %edx,0x14(%ebp)
  8005c9:	89 74 24 04          	mov    %esi,0x4(%esp)
  8005cd:	8b 00                	mov    (%eax),%eax
  8005cf:	89 04 24             	mov    %eax,(%esp)
  8005d2:	ff d7                	call   *%edi
  8005d4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8005d7:	e9 fd fe ff ff       	jmp    8004d9 <vprintfmt+0x2c>
  8005dc:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  8005df:	8b 45 14             	mov    0x14(%ebp),%eax
  8005e2:	8d 50 04             	lea    0x4(%eax),%edx
  8005e5:	89 55 14             	mov    %edx,0x14(%ebp)
  8005e8:	8b 00                	mov    (%eax),%eax
  8005ea:	89 c2                	mov    %eax,%edx
  8005ec:	c1 fa 1f             	sar    $0x1f,%edx
  8005ef:	31 d0                	xor    %edx,%eax
  8005f1:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8005f3:	83 f8 12             	cmp    $0x12,%eax
  8005f6:	7f 0b                	jg     800603 <vprintfmt+0x156>
  8005f8:	8b 14 85 e0 2d 80 00 	mov    0x802de0(,%eax,4),%edx
  8005ff:	85 d2                	test   %edx,%edx
  800601:	75 20                	jne    800623 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  800603:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800607:	c7 44 24 08 47 2b 80 	movl   $0x802b47,0x8(%esp)
  80060e:	00 
  80060f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800613:	89 3c 24             	mov    %edi,(%esp)
  800616:	e8 36 03 00 00       	call   800951 <printfmt>
  80061b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  80061e:	e9 b6 fe ff ff       	jmp    8004d9 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  800623:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800627:	c7 44 24 08 32 2f 80 	movl   $0x802f32,0x8(%esp)
  80062e:	00 
  80062f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800633:	89 3c 24             	mov    %edi,(%esp)
  800636:	e8 16 03 00 00       	call   800951 <printfmt>
  80063b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80063e:	e9 96 fe ff ff       	jmp    8004d9 <vprintfmt+0x2c>
  800643:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800646:	89 c3                	mov    %eax,%ebx
  800648:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  80064b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80064e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  800651:	8b 45 14             	mov    0x14(%ebp),%eax
  800654:	8d 50 04             	lea    0x4(%eax),%edx
  800657:	89 55 14             	mov    %edx,0x14(%ebp)
  80065a:	8b 00                	mov    (%eax),%eax
  80065c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  80065f:	85 c0                	test   %eax,%eax
  800661:	b8 50 2b 80 00       	mov    $0x802b50,%eax
  800666:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  80066a:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  80066d:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  800671:	7e 06                	jle    800679 <vprintfmt+0x1cc>
  800673:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  800677:	75 13                	jne    80068c <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800679:	8b 55 e0             	mov    -0x20(%ebp),%edx
  80067c:	0f be 02             	movsbl (%edx),%eax
  80067f:	85 c0                	test   %eax,%eax
  800681:	0f 85 9b 00 00 00    	jne    800722 <vprintfmt+0x275>
  800687:	e9 88 00 00 00       	jmp    800714 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80068c:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800690:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800693:	89 0c 24             	mov    %ecx,(%esp)
  800696:	e8 00 03 00 00       	call   80099b <strnlen>
  80069b:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  80069e:	29 c2                	sub    %eax,%edx
  8006a0:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8006a3:	85 d2                	test   %edx,%edx
  8006a5:	7e d2                	jle    800679 <vprintfmt+0x1cc>
					putch(padc, putdat);
  8006a7:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  8006ab:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  8006ae:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  8006b1:	89 d3                	mov    %edx,%ebx
  8006b3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8006b7:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8006ba:	89 04 24             	mov    %eax,(%esp)
  8006bd:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  8006bf:	83 eb 01             	sub    $0x1,%ebx
  8006c2:	85 db                	test   %ebx,%ebx
  8006c4:	7f ed                	jg     8006b3 <vprintfmt+0x206>
  8006c6:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  8006c9:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  8006d0:	eb a7                	jmp    800679 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8006d2:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8006d6:	74 1a                	je     8006f2 <vprintfmt+0x245>
  8006d8:	8d 50 e0             	lea    -0x20(%eax),%edx
  8006db:	83 fa 5e             	cmp    $0x5e,%edx
  8006de:	76 12                	jbe    8006f2 <vprintfmt+0x245>
					putch('?', putdat);
  8006e0:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8006e4:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  8006eb:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8006ee:	66 90                	xchg   %ax,%ax
  8006f0:	eb 0a                	jmp    8006fc <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  8006f2:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8006f6:	89 04 24             	mov    %eax,(%esp)
  8006f9:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8006fc:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  800700:	0f be 03             	movsbl (%ebx),%eax
  800703:	85 c0                	test   %eax,%eax
  800705:	74 05                	je     80070c <vprintfmt+0x25f>
  800707:	83 c3 01             	add    $0x1,%ebx
  80070a:	eb 29                	jmp    800735 <vprintfmt+0x288>
  80070c:	89 fe                	mov    %edi,%esi
  80070e:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800711:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  800714:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  800718:	7f 2e                	jg     800748 <vprintfmt+0x29b>
  80071a:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80071d:	e9 b7 fd ff ff       	jmp    8004d9 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800722:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800725:	83 c2 01             	add    $0x1,%edx
  800728:	89 7d e0             	mov    %edi,-0x20(%ebp)
  80072b:	89 f7                	mov    %esi,%edi
  80072d:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800730:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800733:	89 d3                	mov    %edx,%ebx
  800735:	85 f6                	test   %esi,%esi
  800737:	78 99                	js     8006d2 <vprintfmt+0x225>
  800739:	83 ee 01             	sub    $0x1,%esi
  80073c:	79 94                	jns    8006d2 <vprintfmt+0x225>
  80073e:	89 fe                	mov    %edi,%esi
  800740:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800743:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  800746:	eb cc                	jmp    800714 <vprintfmt+0x267>
  800748:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  80074b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  80074e:	89 74 24 04          	mov    %esi,0x4(%esp)
  800752:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  800759:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  80075b:	83 eb 01             	sub    $0x1,%ebx
  80075e:	85 db                	test   %ebx,%ebx
  800760:	7f ec                	jg     80074e <vprintfmt+0x2a1>
  800762:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  800765:	e9 6f fd ff ff       	jmp    8004d9 <vprintfmt+0x2c>
  80076a:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  80076d:	83 f9 01             	cmp    $0x1,%ecx
  800770:	7e 16                	jle    800788 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  800772:	8b 45 14             	mov    0x14(%ebp),%eax
  800775:	8d 50 08             	lea    0x8(%eax),%edx
  800778:	89 55 14             	mov    %edx,0x14(%ebp)
  80077b:	8b 10                	mov    (%eax),%edx
  80077d:	8b 48 04             	mov    0x4(%eax),%ecx
  800780:	89 55 d8             	mov    %edx,-0x28(%ebp)
  800783:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800786:	eb 32                	jmp    8007ba <vprintfmt+0x30d>
	else if (lflag)
  800788:	85 c9                	test   %ecx,%ecx
  80078a:	74 18                	je     8007a4 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  80078c:	8b 45 14             	mov    0x14(%ebp),%eax
  80078f:	8d 50 04             	lea    0x4(%eax),%edx
  800792:	89 55 14             	mov    %edx,0x14(%ebp)
  800795:	8b 00                	mov    (%eax),%eax
  800797:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80079a:	89 c1                	mov    %eax,%ecx
  80079c:	c1 f9 1f             	sar    $0x1f,%ecx
  80079f:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8007a2:	eb 16                	jmp    8007ba <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  8007a4:	8b 45 14             	mov    0x14(%ebp),%eax
  8007a7:	8d 50 04             	lea    0x4(%eax),%edx
  8007aa:	89 55 14             	mov    %edx,0x14(%ebp)
  8007ad:	8b 00                	mov    (%eax),%eax
  8007af:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8007b2:	89 c2                	mov    %eax,%edx
  8007b4:	c1 fa 1f             	sar    $0x1f,%edx
  8007b7:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  8007ba:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8007bd:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8007c0:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  8007c5:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  8007c9:	0f 89 9b 00 00 00    	jns    80086a <vprintfmt+0x3bd>
				putch('-', putdat);
  8007cf:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007d3:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  8007da:	ff d7                	call   *%edi
				num = -(long long) num;
  8007dc:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8007df:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8007e2:	f7 d9                	neg    %ecx
  8007e4:	83 d3 00             	adc    $0x0,%ebx
  8007e7:	f7 db                	neg    %ebx
  8007e9:	b8 0a 00 00 00       	mov    $0xa,%eax
  8007ee:	eb 7a                	jmp    80086a <vprintfmt+0x3bd>
  8007f0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  8007f3:	89 ca                	mov    %ecx,%edx
  8007f5:	8d 45 14             	lea    0x14(%ebp),%eax
  8007f8:	e8 59 fc ff ff       	call   800456 <getuint>
  8007fd:	89 c1                	mov    %eax,%ecx
  8007ff:	89 d3                	mov    %edx,%ebx
  800801:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  800806:	eb 62                	jmp    80086a <vprintfmt+0x3bd>
  800808:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  80080b:	89 ca                	mov    %ecx,%edx
  80080d:	8d 45 14             	lea    0x14(%ebp),%eax
  800810:	e8 41 fc ff ff       	call   800456 <getuint>
  800815:	89 c1                	mov    %eax,%ecx
  800817:	89 d3                	mov    %edx,%ebx
  800819:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  80081e:	eb 4a                	jmp    80086a <vprintfmt+0x3bd>
  800820:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  800823:	89 74 24 04          	mov    %esi,0x4(%esp)
  800827:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  80082e:	ff d7                	call   *%edi
			putch('x', putdat);
  800830:	89 74 24 04          	mov    %esi,0x4(%esp)
  800834:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  80083b:	ff d7                	call   *%edi
			num = (unsigned long long)
  80083d:	8b 45 14             	mov    0x14(%ebp),%eax
  800840:	8d 50 04             	lea    0x4(%eax),%edx
  800843:	89 55 14             	mov    %edx,0x14(%ebp)
  800846:	8b 08                	mov    (%eax),%ecx
  800848:	bb 00 00 00 00       	mov    $0x0,%ebx
  80084d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  800852:	eb 16                	jmp    80086a <vprintfmt+0x3bd>
  800854:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  800857:	89 ca                	mov    %ecx,%edx
  800859:	8d 45 14             	lea    0x14(%ebp),%eax
  80085c:	e8 f5 fb ff ff       	call   800456 <getuint>
  800861:	89 c1                	mov    %eax,%ecx
  800863:	89 d3                	mov    %edx,%ebx
  800865:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  80086a:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  80086e:	89 54 24 10          	mov    %edx,0x10(%esp)
  800872:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800875:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800879:	89 44 24 08          	mov    %eax,0x8(%esp)
  80087d:	89 0c 24             	mov    %ecx,(%esp)
  800880:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800884:	89 f2                	mov    %esi,%edx
  800886:	89 f8                	mov    %edi,%eax
  800888:	e8 d3 fa ff ff       	call   800360 <printnum>
  80088d:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800890:	e9 44 fc ff ff       	jmp    8004d9 <vprintfmt+0x2c>
  800895:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800898:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  80089b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80089f:	89 14 24             	mov    %edx,(%esp)
  8008a2:	ff d7                	call   *%edi
  8008a4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8008a7:	e9 2d fc ff ff       	jmp    8004d9 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  8008ac:	89 74 24 04          	mov    %esi,0x4(%esp)
  8008b0:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  8008b7:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  8008b9:	8d 43 ff             	lea    -0x1(%ebx),%eax
  8008bc:	80 38 25             	cmpb   $0x25,(%eax)
  8008bf:	0f 84 14 fc ff ff    	je     8004d9 <vprintfmt+0x2c>
  8008c5:	89 c3                	mov    %eax,%ebx
  8008c7:	eb f0                	jmp    8008b9 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  8008c9:	83 c4 5c             	add    $0x5c,%esp
  8008cc:	5b                   	pop    %ebx
  8008cd:	5e                   	pop    %esi
  8008ce:	5f                   	pop    %edi
  8008cf:	5d                   	pop    %ebp
  8008d0:	c3                   	ret    

008008d1 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  8008d1:	55                   	push   %ebp
  8008d2:	89 e5                	mov    %esp,%ebp
  8008d4:	83 ec 28             	sub    $0x28,%esp
  8008d7:	8b 45 08             	mov    0x8(%ebp),%eax
  8008da:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  8008dd:	85 c0                	test   %eax,%eax
  8008df:	74 04                	je     8008e5 <vsnprintf+0x14>
  8008e1:	85 d2                	test   %edx,%edx
  8008e3:	7f 07                	jg     8008ec <vsnprintf+0x1b>
  8008e5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8008ea:	eb 3b                	jmp    800927 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  8008ec:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8008ef:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  8008f3:	89 45 f0             	mov    %eax,-0x10(%ebp)
  8008f6:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  8008fd:	8b 45 14             	mov    0x14(%ebp),%eax
  800900:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800904:	8b 45 10             	mov    0x10(%ebp),%eax
  800907:	89 44 24 08          	mov    %eax,0x8(%esp)
  80090b:	8d 45 ec             	lea    -0x14(%ebp),%eax
  80090e:	89 44 24 04          	mov    %eax,0x4(%esp)
  800912:	c7 04 24 90 04 80 00 	movl   $0x800490,(%esp)
  800919:	e8 8f fb ff ff       	call   8004ad <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  80091e:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800921:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  800924:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  800927:	c9                   	leave  
  800928:	c3                   	ret    

00800929 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  800929:	55                   	push   %ebp
  80092a:	89 e5                	mov    %esp,%ebp
  80092c:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  80092f:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800932:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800936:	8b 45 10             	mov    0x10(%ebp),%eax
  800939:	89 44 24 08          	mov    %eax,0x8(%esp)
  80093d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800940:	89 44 24 04          	mov    %eax,0x4(%esp)
  800944:	8b 45 08             	mov    0x8(%ebp),%eax
  800947:	89 04 24             	mov    %eax,(%esp)
  80094a:	e8 82 ff ff ff       	call   8008d1 <vsnprintf>
	va_end(ap);

	return rc;
}
  80094f:	c9                   	leave  
  800950:	c3                   	ret    

00800951 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800951:	55                   	push   %ebp
  800952:	89 e5                	mov    %esp,%ebp
  800954:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800957:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  80095a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80095e:	8b 45 10             	mov    0x10(%ebp),%eax
  800961:	89 44 24 08          	mov    %eax,0x8(%esp)
  800965:	8b 45 0c             	mov    0xc(%ebp),%eax
  800968:	89 44 24 04          	mov    %eax,0x4(%esp)
  80096c:	8b 45 08             	mov    0x8(%ebp),%eax
  80096f:	89 04 24             	mov    %eax,(%esp)
  800972:	e8 36 fb ff ff       	call   8004ad <vprintfmt>
	va_end(ap);
}
  800977:	c9                   	leave  
  800978:	c3                   	ret    
  800979:	00 00                	add    %al,(%eax)
  80097b:	00 00                	add    %al,(%eax)
  80097d:	00 00                	add    %al,(%eax)
	...

00800980 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800980:	55                   	push   %ebp
  800981:	89 e5                	mov    %esp,%ebp
  800983:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800986:	b8 00 00 00 00       	mov    $0x0,%eax
  80098b:	80 3a 00             	cmpb   $0x0,(%edx)
  80098e:	74 09                	je     800999 <strlen+0x19>
		n++;
  800990:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800993:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800997:	75 f7                	jne    800990 <strlen+0x10>
		n++;
	return n;
}
  800999:	5d                   	pop    %ebp
  80099a:	c3                   	ret    

0080099b <strnlen>:

int
strnlen(const char *s, size_t size)
{
  80099b:	55                   	push   %ebp
  80099c:	89 e5                	mov    %esp,%ebp
  80099e:	53                   	push   %ebx
  80099f:	8b 5d 08             	mov    0x8(%ebp),%ebx
  8009a2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  8009a5:	85 c9                	test   %ecx,%ecx
  8009a7:	74 19                	je     8009c2 <strnlen+0x27>
  8009a9:	80 3b 00             	cmpb   $0x0,(%ebx)
  8009ac:	74 14                	je     8009c2 <strnlen+0x27>
  8009ae:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  8009b3:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  8009b6:	39 c8                	cmp    %ecx,%eax
  8009b8:	74 0d                	je     8009c7 <strnlen+0x2c>
  8009ba:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  8009be:	75 f3                	jne    8009b3 <strnlen+0x18>
  8009c0:	eb 05                	jmp    8009c7 <strnlen+0x2c>
  8009c2:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  8009c7:	5b                   	pop    %ebx
  8009c8:	5d                   	pop    %ebp
  8009c9:	c3                   	ret    

008009ca <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  8009ca:	55                   	push   %ebp
  8009cb:	89 e5                	mov    %esp,%ebp
  8009cd:	53                   	push   %ebx
  8009ce:	8b 45 08             	mov    0x8(%ebp),%eax
  8009d1:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  8009d4:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  8009d9:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  8009dd:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  8009e0:	83 c2 01             	add    $0x1,%edx
  8009e3:	84 c9                	test   %cl,%cl
  8009e5:	75 f2                	jne    8009d9 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  8009e7:	5b                   	pop    %ebx
  8009e8:	5d                   	pop    %ebp
  8009e9:	c3                   	ret    

008009ea <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  8009ea:	55                   	push   %ebp
  8009eb:	89 e5                	mov    %esp,%ebp
  8009ed:	56                   	push   %esi
  8009ee:	53                   	push   %ebx
  8009ef:	8b 45 08             	mov    0x8(%ebp),%eax
  8009f2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8009f5:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8009f8:	85 f6                	test   %esi,%esi
  8009fa:	74 18                	je     800a14 <strncpy+0x2a>
  8009fc:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  800a01:	0f b6 1a             	movzbl (%edx),%ebx
  800a04:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800a07:	80 3a 01             	cmpb   $0x1,(%edx)
  800a0a:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800a0d:	83 c1 01             	add    $0x1,%ecx
  800a10:	39 ce                	cmp    %ecx,%esi
  800a12:	77 ed                	ja     800a01 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  800a14:	5b                   	pop    %ebx
  800a15:	5e                   	pop    %esi
  800a16:	5d                   	pop    %ebp
  800a17:	c3                   	ret    

00800a18 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800a18:	55                   	push   %ebp
  800a19:	89 e5                	mov    %esp,%ebp
  800a1b:	56                   	push   %esi
  800a1c:	53                   	push   %ebx
  800a1d:	8b 75 08             	mov    0x8(%ebp),%esi
  800a20:	8b 55 0c             	mov    0xc(%ebp),%edx
  800a23:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800a26:	89 f0                	mov    %esi,%eax
  800a28:	85 c9                	test   %ecx,%ecx
  800a2a:	74 27                	je     800a53 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  800a2c:	83 e9 01             	sub    $0x1,%ecx
  800a2f:	74 1d                	je     800a4e <strlcpy+0x36>
  800a31:	0f b6 1a             	movzbl (%edx),%ebx
  800a34:	84 db                	test   %bl,%bl
  800a36:	74 16                	je     800a4e <strlcpy+0x36>
			*dst++ = *src++;
  800a38:	88 18                	mov    %bl,(%eax)
  800a3a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800a3d:	83 e9 01             	sub    $0x1,%ecx
  800a40:	74 0e                	je     800a50 <strlcpy+0x38>
			*dst++ = *src++;
  800a42:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800a45:	0f b6 1a             	movzbl (%edx),%ebx
  800a48:	84 db                	test   %bl,%bl
  800a4a:	75 ec                	jne    800a38 <strlcpy+0x20>
  800a4c:	eb 02                	jmp    800a50 <strlcpy+0x38>
  800a4e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800a50:	c6 00 00             	movb   $0x0,(%eax)
  800a53:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800a55:	5b                   	pop    %ebx
  800a56:	5e                   	pop    %esi
  800a57:	5d                   	pop    %ebp
  800a58:	c3                   	ret    

00800a59 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800a59:	55                   	push   %ebp
  800a5a:	89 e5                	mov    %esp,%ebp
  800a5c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800a5f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800a62:	0f b6 01             	movzbl (%ecx),%eax
  800a65:	84 c0                	test   %al,%al
  800a67:	74 15                	je     800a7e <strcmp+0x25>
  800a69:	3a 02                	cmp    (%edx),%al
  800a6b:	75 11                	jne    800a7e <strcmp+0x25>
		p++, q++;
  800a6d:	83 c1 01             	add    $0x1,%ecx
  800a70:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800a73:	0f b6 01             	movzbl (%ecx),%eax
  800a76:	84 c0                	test   %al,%al
  800a78:	74 04                	je     800a7e <strcmp+0x25>
  800a7a:	3a 02                	cmp    (%edx),%al
  800a7c:	74 ef                	je     800a6d <strcmp+0x14>
  800a7e:	0f b6 c0             	movzbl %al,%eax
  800a81:	0f b6 12             	movzbl (%edx),%edx
  800a84:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800a86:	5d                   	pop    %ebp
  800a87:	c3                   	ret    

00800a88 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800a88:	55                   	push   %ebp
  800a89:	89 e5                	mov    %esp,%ebp
  800a8b:	53                   	push   %ebx
  800a8c:	8b 55 08             	mov    0x8(%ebp),%edx
  800a8f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800a92:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800a95:	85 c0                	test   %eax,%eax
  800a97:	74 23                	je     800abc <strncmp+0x34>
  800a99:	0f b6 1a             	movzbl (%edx),%ebx
  800a9c:	84 db                	test   %bl,%bl
  800a9e:	74 24                	je     800ac4 <strncmp+0x3c>
  800aa0:	3a 19                	cmp    (%ecx),%bl
  800aa2:	75 20                	jne    800ac4 <strncmp+0x3c>
  800aa4:	83 e8 01             	sub    $0x1,%eax
  800aa7:	74 13                	je     800abc <strncmp+0x34>
		n--, p++, q++;
  800aa9:	83 c2 01             	add    $0x1,%edx
  800aac:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800aaf:	0f b6 1a             	movzbl (%edx),%ebx
  800ab2:	84 db                	test   %bl,%bl
  800ab4:	74 0e                	je     800ac4 <strncmp+0x3c>
  800ab6:	3a 19                	cmp    (%ecx),%bl
  800ab8:	74 ea                	je     800aa4 <strncmp+0x1c>
  800aba:	eb 08                	jmp    800ac4 <strncmp+0x3c>
  800abc:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800ac1:	5b                   	pop    %ebx
  800ac2:	5d                   	pop    %ebp
  800ac3:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800ac4:	0f b6 02             	movzbl (%edx),%eax
  800ac7:	0f b6 11             	movzbl (%ecx),%edx
  800aca:	29 d0                	sub    %edx,%eax
  800acc:	eb f3                	jmp    800ac1 <strncmp+0x39>

00800ace <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800ace:	55                   	push   %ebp
  800acf:	89 e5                	mov    %esp,%ebp
  800ad1:	8b 45 08             	mov    0x8(%ebp),%eax
  800ad4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800ad8:	0f b6 10             	movzbl (%eax),%edx
  800adb:	84 d2                	test   %dl,%dl
  800add:	74 15                	je     800af4 <strchr+0x26>
		if (*s == c)
  800adf:	38 ca                	cmp    %cl,%dl
  800ae1:	75 07                	jne    800aea <strchr+0x1c>
  800ae3:	eb 14                	jmp    800af9 <strchr+0x2b>
  800ae5:	38 ca                	cmp    %cl,%dl
  800ae7:	90                   	nop
  800ae8:	74 0f                	je     800af9 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800aea:	83 c0 01             	add    $0x1,%eax
  800aed:	0f b6 10             	movzbl (%eax),%edx
  800af0:	84 d2                	test   %dl,%dl
  800af2:	75 f1                	jne    800ae5 <strchr+0x17>
  800af4:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800af9:	5d                   	pop    %ebp
  800afa:	c3                   	ret    

00800afb <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800afb:	55                   	push   %ebp
  800afc:	89 e5                	mov    %esp,%ebp
  800afe:	8b 45 08             	mov    0x8(%ebp),%eax
  800b01:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800b05:	0f b6 10             	movzbl (%eax),%edx
  800b08:	84 d2                	test   %dl,%dl
  800b0a:	74 18                	je     800b24 <strfind+0x29>
		if (*s == c)
  800b0c:	38 ca                	cmp    %cl,%dl
  800b0e:	75 0a                	jne    800b1a <strfind+0x1f>
  800b10:	eb 12                	jmp    800b24 <strfind+0x29>
  800b12:	38 ca                	cmp    %cl,%dl
  800b14:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800b18:	74 0a                	je     800b24 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800b1a:	83 c0 01             	add    $0x1,%eax
  800b1d:	0f b6 10             	movzbl (%eax),%edx
  800b20:	84 d2                	test   %dl,%dl
  800b22:	75 ee                	jne    800b12 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800b24:	5d                   	pop    %ebp
  800b25:	c3                   	ret    

00800b26 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800b26:	55                   	push   %ebp
  800b27:	89 e5                	mov    %esp,%ebp
  800b29:	83 ec 0c             	sub    $0xc,%esp
  800b2c:	89 1c 24             	mov    %ebx,(%esp)
  800b2f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800b33:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800b37:	8b 7d 08             	mov    0x8(%ebp),%edi
  800b3a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800b3d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800b40:	85 c9                	test   %ecx,%ecx
  800b42:	74 30                	je     800b74 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800b44:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800b4a:	75 25                	jne    800b71 <memset+0x4b>
  800b4c:	f6 c1 03             	test   $0x3,%cl
  800b4f:	75 20                	jne    800b71 <memset+0x4b>
		c &= 0xFF;
  800b51:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800b54:	89 d3                	mov    %edx,%ebx
  800b56:	c1 e3 08             	shl    $0x8,%ebx
  800b59:	89 d6                	mov    %edx,%esi
  800b5b:	c1 e6 18             	shl    $0x18,%esi
  800b5e:	89 d0                	mov    %edx,%eax
  800b60:	c1 e0 10             	shl    $0x10,%eax
  800b63:	09 f0                	or     %esi,%eax
  800b65:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800b67:	09 d8                	or     %ebx,%eax
  800b69:	c1 e9 02             	shr    $0x2,%ecx
  800b6c:	fc                   	cld    
  800b6d:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800b6f:	eb 03                	jmp    800b74 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800b71:	fc                   	cld    
  800b72:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800b74:	89 f8                	mov    %edi,%eax
  800b76:	8b 1c 24             	mov    (%esp),%ebx
  800b79:	8b 74 24 04          	mov    0x4(%esp),%esi
  800b7d:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800b81:	89 ec                	mov    %ebp,%esp
  800b83:	5d                   	pop    %ebp
  800b84:	c3                   	ret    

00800b85 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800b85:	55                   	push   %ebp
  800b86:	89 e5                	mov    %esp,%ebp
  800b88:	83 ec 08             	sub    $0x8,%esp
  800b8b:	89 34 24             	mov    %esi,(%esp)
  800b8e:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800b92:	8b 45 08             	mov    0x8(%ebp),%eax
  800b95:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800b98:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800b9b:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800b9d:	39 c6                	cmp    %eax,%esi
  800b9f:	73 35                	jae    800bd6 <memmove+0x51>
  800ba1:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800ba4:	39 d0                	cmp    %edx,%eax
  800ba6:	73 2e                	jae    800bd6 <memmove+0x51>
		s += n;
		d += n;
  800ba8:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800baa:	f6 c2 03             	test   $0x3,%dl
  800bad:	75 1b                	jne    800bca <memmove+0x45>
  800baf:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800bb5:	75 13                	jne    800bca <memmove+0x45>
  800bb7:	f6 c1 03             	test   $0x3,%cl
  800bba:	75 0e                	jne    800bca <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800bbc:	83 ef 04             	sub    $0x4,%edi
  800bbf:	8d 72 fc             	lea    -0x4(%edx),%esi
  800bc2:	c1 e9 02             	shr    $0x2,%ecx
  800bc5:	fd                   	std    
  800bc6:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800bc8:	eb 09                	jmp    800bd3 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800bca:	83 ef 01             	sub    $0x1,%edi
  800bcd:	8d 72 ff             	lea    -0x1(%edx),%esi
  800bd0:	fd                   	std    
  800bd1:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800bd3:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800bd4:	eb 20                	jmp    800bf6 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800bd6:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800bdc:	75 15                	jne    800bf3 <memmove+0x6e>
  800bde:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800be4:	75 0d                	jne    800bf3 <memmove+0x6e>
  800be6:	f6 c1 03             	test   $0x3,%cl
  800be9:	75 08                	jne    800bf3 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800beb:	c1 e9 02             	shr    $0x2,%ecx
  800bee:	fc                   	cld    
  800bef:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800bf1:	eb 03                	jmp    800bf6 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800bf3:	fc                   	cld    
  800bf4:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800bf6:	8b 34 24             	mov    (%esp),%esi
  800bf9:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800bfd:	89 ec                	mov    %ebp,%esp
  800bff:	5d                   	pop    %ebp
  800c00:	c3                   	ret    

00800c01 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800c01:	55                   	push   %ebp
  800c02:	89 e5                	mov    %esp,%ebp
  800c04:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800c07:	8b 45 10             	mov    0x10(%ebp),%eax
  800c0a:	89 44 24 08          	mov    %eax,0x8(%esp)
  800c0e:	8b 45 0c             	mov    0xc(%ebp),%eax
  800c11:	89 44 24 04          	mov    %eax,0x4(%esp)
  800c15:	8b 45 08             	mov    0x8(%ebp),%eax
  800c18:	89 04 24             	mov    %eax,(%esp)
  800c1b:	e8 65 ff ff ff       	call   800b85 <memmove>
}
  800c20:	c9                   	leave  
  800c21:	c3                   	ret    

00800c22 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800c22:	55                   	push   %ebp
  800c23:	89 e5                	mov    %esp,%ebp
  800c25:	57                   	push   %edi
  800c26:	56                   	push   %esi
  800c27:	53                   	push   %ebx
  800c28:	8b 75 08             	mov    0x8(%ebp),%esi
  800c2b:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800c2e:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800c31:	85 c9                	test   %ecx,%ecx
  800c33:	74 36                	je     800c6b <memcmp+0x49>
		if (*s1 != *s2)
  800c35:	0f b6 06             	movzbl (%esi),%eax
  800c38:	0f b6 1f             	movzbl (%edi),%ebx
  800c3b:	38 d8                	cmp    %bl,%al
  800c3d:	74 20                	je     800c5f <memcmp+0x3d>
  800c3f:	eb 14                	jmp    800c55 <memcmp+0x33>
  800c41:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800c46:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800c4b:	83 c2 01             	add    $0x1,%edx
  800c4e:	83 e9 01             	sub    $0x1,%ecx
  800c51:	38 d8                	cmp    %bl,%al
  800c53:	74 12                	je     800c67 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800c55:	0f b6 c0             	movzbl %al,%eax
  800c58:	0f b6 db             	movzbl %bl,%ebx
  800c5b:	29 d8                	sub    %ebx,%eax
  800c5d:	eb 11                	jmp    800c70 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800c5f:	83 e9 01             	sub    $0x1,%ecx
  800c62:	ba 00 00 00 00       	mov    $0x0,%edx
  800c67:	85 c9                	test   %ecx,%ecx
  800c69:	75 d6                	jne    800c41 <memcmp+0x1f>
  800c6b:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800c70:	5b                   	pop    %ebx
  800c71:	5e                   	pop    %esi
  800c72:	5f                   	pop    %edi
  800c73:	5d                   	pop    %ebp
  800c74:	c3                   	ret    

00800c75 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800c75:	55                   	push   %ebp
  800c76:	89 e5                	mov    %esp,%ebp
  800c78:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800c7b:	89 c2                	mov    %eax,%edx
  800c7d:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800c80:	39 d0                	cmp    %edx,%eax
  800c82:	73 15                	jae    800c99 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800c84:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800c88:	38 08                	cmp    %cl,(%eax)
  800c8a:	75 06                	jne    800c92 <memfind+0x1d>
  800c8c:	eb 0b                	jmp    800c99 <memfind+0x24>
  800c8e:	38 08                	cmp    %cl,(%eax)
  800c90:	74 07                	je     800c99 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800c92:	83 c0 01             	add    $0x1,%eax
  800c95:	39 c2                	cmp    %eax,%edx
  800c97:	77 f5                	ja     800c8e <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800c99:	5d                   	pop    %ebp
  800c9a:	c3                   	ret    

00800c9b <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800c9b:	55                   	push   %ebp
  800c9c:	89 e5                	mov    %esp,%ebp
  800c9e:	57                   	push   %edi
  800c9f:	56                   	push   %esi
  800ca0:	53                   	push   %ebx
  800ca1:	83 ec 04             	sub    $0x4,%esp
  800ca4:	8b 55 08             	mov    0x8(%ebp),%edx
  800ca7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800caa:	0f b6 02             	movzbl (%edx),%eax
  800cad:	3c 20                	cmp    $0x20,%al
  800caf:	74 04                	je     800cb5 <strtol+0x1a>
  800cb1:	3c 09                	cmp    $0x9,%al
  800cb3:	75 0e                	jne    800cc3 <strtol+0x28>
		s++;
  800cb5:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800cb8:	0f b6 02             	movzbl (%edx),%eax
  800cbb:	3c 20                	cmp    $0x20,%al
  800cbd:	74 f6                	je     800cb5 <strtol+0x1a>
  800cbf:	3c 09                	cmp    $0x9,%al
  800cc1:	74 f2                	je     800cb5 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800cc3:	3c 2b                	cmp    $0x2b,%al
  800cc5:	75 0c                	jne    800cd3 <strtol+0x38>
		s++;
  800cc7:	83 c2 01             	add    $0x1,%edx
  800cca:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800cd1:	eb 15                	jmp    800ce8 <strtol+0x4d>
	else if (*s == '-')
  800cd3:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800cda:	3c 2d                	cmp    $0x2d,%al
  800cdc:	75 0a                	jne    800ce8 <strtol+0x4d>
		s++, neg = 1;
  800cde:	83 c2 01             	add    $0x1,%edx
  800ce1:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800ce8:	85 db                	test   %ebx,%ebx
  800cea:	0f 94 c0             	sete   %al
  800ced:	74 05                	je     800cf4 <strtol+0x59>
  800cef:	83 fb 10             	cmp    $0x10,%ebx
  800cf2:	75 18                	jne    800d0c <strtol+0x71>
  800cf4:	80 3a 30             	cmpb   $0x30,(%edx)
  800cf7:	75 13                	jne    800d0c <strtol+0x71>
  800cf9:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800cfd:	8d 76 00             	lea    0x0(%esi),%esi
  800d00:	75 0a                	jne    800d0c <strtol+0x71>
		s += 2, base = 16;
  800d02:	83 c2 02             	add    $0x2,%edx
  800d05:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800d0a:	eb 15                	jmp    800d21 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800d0c:	84 c0                	test   %al,%al
  800d0e:	66 90                	xchg   %ax,%ax
  800d10:	74 0f                	je     800d21 <strtol+0x86>
  800d12:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800d17:	80 3a 30             	cmpb   $0x30,(%edx)
  800d1a:	75 05                	jne    800d21 <strtol+0x86>
		s++, base = 8;
  800d1c:	83 c2 01             	add    $0x1,%edx
  800d1f:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800d21:	b8 00 00 00 00       	mov    $0x0,%eax
  800d26:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800d28:	0f b6 0a             	movzbl (%edx),%ecx
  800d2b:	89 cf                	mov    %ecx,%edi
  800d2d:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800d30:	80 fb 09             	cmp    $0x9,%bl
  800d33:	77 08                	ja     800d3d <strtol+0xa2>
			dig = *s - '0';
  800d35:	0f be c9             	movsbl %cl,%ecx
  800d38:	83 e9 30             	sub    $0x30,%ecx
  800d3b:	eb 1e                	jmp    800d5b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800d3d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800d40:	80 fb 19             	cmp    $0x19,%bl
  800d43:	77 08                	ja     800d4d <strtol+0xb2>
			dig = *s - 'a' + 10;
  800d45:	0f be c9             	movsbl %cl,%ecx
  800d48:	83 e9 57             	sub    $0x57,%ecx
  800d4b:	eb 0e                	jmp    800d5b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800d4d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800d50:	80 fb 19             	cmp    $0x19,%bl
  800d53:	77 15                	ja     800d6a <strtol+0xcf>
			dig = *s - 'A' + 10;
  800d55:	0f be c9             	movsbl %cl,%ecx
  800d58:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800d5b:	39 f1                	cmp    %esi,%ecx
  800d5d:	7d 0b                	jge    800d6a <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800d5f:	83 c2 01             	add    $0x1,%edx
  800d62:	0f af c6             	imul   %esi,%eax
  800d65:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800d68:	eb be                	jmp    800d28 <strtol+0x8d>
  800d6a:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800d6c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800d70:	74 05                	je     800d77 <strtol+0xdc>
		*endptr = (char *) s;
  800d72:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800d75:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800d77:	89 ca                	mov    %ecx,%edx
  800d79:	f7 da                	neg    %edx
  800d7b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800d7f:	0f 45 c2             	cmovne %edx,%eax
}
  800d82:	83 c4 04             	add    $0x4,%esp
  800d85:	5b                   	pop    %ebx
  800d86:	5e                   	pop    %esi
  800d87:	5f                   	pop    %edi
  800d88:	5d                   	pop    %ebp
  800d89:	c3                   	ret    
	...

00800d8c <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800d8c:	55                   	push   %ebp
  800d8d:	89 e5                	mov    %esp,%ebp
  800d8f:	83 ec 0c             	sub    $0xc,%esp
  800d92:	89 1c 24             	mov    %ebx,(%esp)
  800d95:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d99:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d9d:	ba 00 00 00 00       	mov    $0x0,%edx
  800da2:	b8 01 00 00 00       	mov    $0x1,%eax
  800da7:	89 d1                	mov    %edx,%ecx
  800da9:	89 d3                	mov    %edx,%ebx
  800dab:	89 d7                	mov    %edx,%edi
  800dad:	89 d6                	mov    %edx,%esi
  800daf:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800db1:	8b 1c 24             	mov    (%esp),%ebx
  800db4:	8b 74 24 04          	mov    0x4(%esp),%esi
  800db8:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800dbc:	89 ec                	mov    %ebp,%esp
  800dbe:	5d                   	pop    %ebp
  800dbf:	c3                   	ret    

00800dc0 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800dc0:	55                   	push   %ebp
  800dc1:	89 e5                	mov    %esp,%ebp
  800dc3:	83 ec 0c             	sub    $0xc,%esp
  800dc6:	89 1c 24             	mov    %ebx,(%esp)
  800dc9:	89 74 24 04          	mov    %esi,0x4(%esp)
  800dcd:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800dd1:	b8 00 00 00 00       	mov    $0x0,%eax
  800dd6:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800dd9:	8b 55 08             	mov    0x8(%ebp),%edx
  800ddc:	89 c3                	mov    %eax,%ebx
  800dde:	89 c7                	mov    %eax,%edi
  800de0:	89 c6                	mov    %eax,%esi
  800de2:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800de4:	8b 1c 24             	mov    (%esp),%ebx
  800de7:	8b 74 24 04          	mov    0x4(%esp),%esi
  800deb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800def:	89 ec                	mov    %ebp,%esp
  800df1:	5d                   	pop    %ebp
  800df2:	c3                   	ret    

00800df3 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  800df3:	55                   	push   %ebp
  800df4:	89 e5                	mov    %esp,%ebp
  800df6:	83 ec 0c             	sub    $0xc,%esp
  800df9:	89 1c 24             	mov    %ebx,(%esp)
  800dfc:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e00:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e04:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e09:	b8 10 00 00 00       	mov    $0x10,%eax
  800e0e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e11:	8b 55 08             	mov    0x8(%ebp),%edx
  800e14:	89 df                	mov    %ebx,%edi
  800e16:	89 de                	mov    %ebx,%esi
  800e18:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800e1a:	8b 1c 24             	mov    (%esp),%ebx
  800e1d:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e21:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e25:	89 ec                	mov    %ebp,%esp
  800e27:	5d                   	pop    %ebp
  800e28:	c3                   	ret    

00800e29 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  800e29:	55                   	push   %ebp
  800e2a:	89 e5                	mov    %esp,%ebp
  800e2c:	83 ec 0c             	sub    $0xc,%esp
  800e2f:	89 1c 24             	mov    %ebx,(%esp)
  800e32:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e36:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e3a:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e3f:	b8 0f 00 00 00       	mov    $0xf,%eax
  800e44:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e47:	8b 55 08             	mov    0x8(%ebp),%edx
  800e4a:	89 df                	mov    %ebx,%edi
  800e4c:	89 de                	mov    %ebx,%esi
  800e4e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800e50:	8b 1c 24             	mov    (%esp),%ebx
  800e53:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e57:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e5b:	89 ec                	mov    %ebp,%esp
  800e5d:	5d                   	pop    %ebp
  800e5e:	c3                   	ret    

00800e5f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  800e5f:	55                   	push   %ebp
  800e60:	89 e5                	mov    %esp,%ebp
  800e62:	83 ec 0c             	sub    $0xc,%esp
  800e65:	89 1c 24             	mov    %ebx,(%esp)
  800e68:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e6c:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e70:	ba 00 00 00 00       	mov    $0x0,%edx
  800e75:	b8 0e 00 00 00       	mov    $0xe,%eax
  800e7a:	89 d1                	mov    %edx,%ecx
  800e7c:	89 d3                	mov    %edx,%ebx
  800e7e:	89 d7                	mov    %edx,%edi
  800e80:	89 d6                	mov    %edx,%esi
  800e82:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  800e84:	8b 1c 24             	mov    (%esp),%ebx
  800e87:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e8b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e8f:	89 ec                	mov    %ebp,%esp
  800e91:	5d                   	pop    %ebp
  800e92:	c3                   	ret    

00800e93 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  800e93:	55                   	push   %ebp
  800e94:	89 e5                	mov    %esp,%ebp
  800e96:	83 ec 38             	sub    $0x38,%esp
  800e99:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800e9c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800e9f:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800ea2:	b9 00 00 00 00       	mov    $0x0,%ecx
  800ea7:	b8 0d 00 00 00       	mov    $0xd,%eax
  800eac:	8b 55 08             	mov    0x8(%ebp),%edx
  800eaf:	89 cb                	mov    %ecx,%ebx
  800eb1:	89 cf                	mov    %ecx,%edi
  800eb3:	89 ce                	mov    %ecx,%esi
  800eb5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800eb7:	85 c0                	test   %eax,%eax
  800eb9:	7e 28                	jle    800ee3 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  800ebb:	89 44 24 10          	mov    %eax,0x10(%esp)
  800ebf:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  800ec6:	00 
  800ec7:	c7 44 24 08 4b 2e 80 	movl   $0x802e4b,0x8(%esp)
  800ece:	00 
  800ecf:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800ed6:	00 
  800ed7:	c7 04 24 68 2e 80 00 	movl   $0x802e68,(%esp)
  800ede:	e8 59 f3 ff ff       	call   80023c <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  800ee3:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800ee6:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800ee9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800eec:	89 ec                	mov    %ebp,%esp
  800eee:	5d                   	pop    %ebp
  800eef:	c3                   	ret    

00800ef0 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  800ef0:	55                   	push   %ebp
  800ef1:	89 e5                	mov    %esp,%ebp
  800ef3:	83 ec 38             	sub    $0x38,%esp
  800ef6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800ef9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800efc:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800eff:	be 00 00 00 00       	mov    $0x0,%esi
  800f04:	b8 0c 00 00 00       	mov    $0xc,%eax
  800f09:	8b 7d 14             	mov    0x14(%ebp),%edi
  800f0c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800f0f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f12:	8b 55 08             	mov    0x8(%ebp),%edx
  800f15:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f17:	85 c0                	test   %eax,%eax
  800f19:	7e 28                	jle    800f43 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f1b:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f1f:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  800f26:	00 
  800f27:	c7 44 24 08 4b 2e 80 	movl   $0x802e4b,0x8(%esp)
  800f2e:	00 
  800f2f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f36:	00 
  800f37:	c7 04 24 68 2e 80 00 	movl   $0x802e68,(%esp)
  800f3e:	e8 f9 f2 ff ff       	call   80023c <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  800f43:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800f46:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800f49:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800f4c:	89 ec                	mov    %ebp,%esp
  800f4e:	5d                   	pop    %ebp
  800f4f:	c3                   	ret    

00800f50 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  800f50:	55                   	push   %ebp
  800f51:	89 e5                	mov    %esp,%ebp
  800f53:	83 ec 38             	sub    $0x38,%esp
  800f56:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800f59:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800f5c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f5f:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f64:	b8 0a 00 00 00       	mov    $0xa,%eax
  800f69:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f6c:	8b 55 08             	mov    0x8(%ebp),%edx
  800f6f:	89 df                	mov    %ebx,%edi
  800f71:	89 de                	mov    %ebx,%esi
  800f73:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f75:	85 c0                	test   %eax,%eax
  800f77:	7e 28                	jle    800fa1 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f79:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f7d:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  800f84:	00 
  800f85:	c7 44 24 08 4b 2e 80 	movl   $0x802e4b,0x8(%esp)
  800f8c:	00 
  800f8d:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f94:	00 
  800f95:	c7 04 24 68 2e 80 00 	movl   $0x802e68,(%esp)
  800f9c:	e8 9b f2 ff ff       	call   80023c <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  800fa1:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800fa4:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800fa7:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800faa:	89 ec                	mov    %ebp,%esp
  800fac:	5d                   	pop    %ebp
  800fad:	c3                   	ret    

00800fae <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  800fae:	55                   	push   %ebp
  800faf:	89 e5                	mov    %esp,%ebp
  800fb1:	83 ec 38             	sub    $0x38,%esp
  800fb4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800fb7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800fba:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fbd:	bb 00 00 00 00       	mov    $0x0,%ebx
  800fc2:	b8 09 00 00 00       	mov    $0x9,%eax
  800fc7:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800fca:	8b 55 08             	mov    0x8(%ebp),%edx
  800fcd:	89 df                	mov    %ebx,%edi
  800fcf:	89 de                	mov    %ebx,%esi
  800fd1:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800fd3:	85 c0                	test   %eax,%eax
  800fd5:	7e 28                	jle    800fff <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800fd7:	89 44 24 10          	mov    %eax,0x10(%esp)
  800fdb:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  800fe2:	00 
  800fe3:	c7 44 24 08 4b 2e 80 	movl   $0x802e4b,0x8(%esp)
  800fea:	00 
  800feb:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800ff2:	00 
  800ff3:	c7 04 24 68 2e 80 00 	movl   $0x802e68,(%esp)
  800ffa:	e8 3d f2 ff ff       	call   80023c <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  800fff:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801002:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801005:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801008:	89 ec                	mov    %ebp,%esp
  80100a:	5d                   	pop    %ebp
  80100b:	c3                   	ret    

0080100c <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  80100c:	55                   	push   %ebp
  80100d:	89 e5                	mov    %esp,%ebp
  80100f:	83 ec 38             	sub    $0x38,%esp
  801012:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801015:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801018:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80101b:	bb 00 00 00 00       	mov    $0x0,%ebx
  801020:	b8 08 00 00 00       	mov    $0x8,%eax
  801025:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801028:	8b 55 08             	mov    0x8(%ebp),%edx
  80102b:	89 df                	mov    %ebx,%edi
  80102d:	89 de                	mov    %ebx,%esi
  80102f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801031:	85 c0                	test   %eax,%eax
  801033:	7e 28                	jle    80105d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801035:	89 44 24 10          	mov    %eax,0x10(%esp)
  801039:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  801040:	00 
  801041:	c7 44 24 08 4b 2e 80 	movl   $0x802e4b,0x8(%esp)
  801048:	00 
  801049:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801050:	00 
  801051:	c7 04 24 68 2e 80 00 	movl   $0x802e68,(%esp)
  801058:	e8 df f1 ff ff       	call   80023c <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  80105d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801060:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801063:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801066:	89 ec                	mov    %ebp,%esp
  801068:	5d                   	pop    %ebp
  801069:	c3                   	ret    

0080106a <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  80106a:	55                   	push   %ebp
  80106b:	89 e5                	mov    %esp,%ebp
  80106d:	83 ec 38             	sub    $0x38,%esp
  801070:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801073:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801076:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801079:	bb 00 00 00 00       	mov    $0x0,%ebx
  80107e:	b8 06 00 00 00       	mov    $0x6,%eax
  801083:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801086:	8b 55 08             	mov    0x8(%ebp),%edx
  801089:	89 df                	mov    %ebx,%edi
  80108b:	89 de                	mov    %ebx,%esi
  80108d:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80108f:	85 c0                	test   %eax,%eax
  801091:	7e 28                	jle    8010bb <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801093:	89 44 24 10          	mov    %eax,0x10(%esp)
  801097:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  80109e:	00 
  80109f:	c7 44 24 08 4b 2e 80 	movl   $0x802e4b,0x8(%esp)
  8010a6:	00 
  8010a7:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8010ae:	00 
  8010af:	c7 04 24 68 2e 80 00 	movl   $0x802e68,(%esp)
  8010b6:	e8 81 f1 ff ff       	call   80023c <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  8010bb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8010be:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8010c1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8010c4:	89 ec                	mov    %ebp,%esp
  8010c6:	5d                   	pop    %ebp
  8010c7:	c3                   	ret    

008010c8 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  8010c8:	55                   	push   %ebp
  8010c9:	89 e5                	mov    %esp,%ebp
  8010cb:	83 ec 38             	sub    $0x38,%esp
  8010ce:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010d1:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010d4:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010d7:	b8 05 00 00 00       	mov    $0x5,%eax
  8010dc:	8b 75 18             	mov    0x18(%ebp),%esi
  8010df:	8b 7d 14             	mov    0x14(%ebp),%edi
  8010e2:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8010e5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8010e8:	8b 55 08             	mov    0x8(%ebp),%edx
  8010eb:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010ed:	85 c0                	test   %eax,%eax
  8010ef:	7e 28                	jle    801119 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010f1:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010f5:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  8010fc:	00 
  8010fd:	c7 44 24 08 4b 2e 80 	movl   $0x802e4b,0x8(%esp)
  801104:	00 
  801105:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80110c:	00 
  80110d:	c7 04 24 68 2e 80 00 	movl   $0x802e68,(%esp)
  801114:	e8 23 f1 ff ff       	call   80023c <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  801119:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80111c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80111f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801122:	89 ec                	mov    %ebp,%esp
  801124:	5d                   	pop    %ebp
  801125:	c3                   	ret    

00801126 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  801126:	55                   	push   %ebp
  801127:	89 e5                	mov    %esp,%ebp
  801129:	83 ec 38             	sub    $0x38,%esp
  80112c:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80112f:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801132:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801135:	be 00 00 00 00       	mov    $0x0,%esi
  80113a:	b8 04 00 00 00       	mov    $0x4,%eax
  80113f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801142:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801145:	8b 55 08             	mov    0x8(%ebp),%edx
  801148:	89 f7                	mov    %esi,%edi
  80114a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80114c:	85 c0                	test   %eax,%eax
  80114e:	7e 28                	jle    801178 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  801150:	89 44 24 10          	mov    %eax,0x10(%esp)
  801154:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  80115b:	00 
  80115c:	c7 44 24 08 4b 2e 80 	movl   $0x802e4b,0x8(%esp)
  801163:	00 
  801164:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80116b:	00 
  80116c:	c7 04 24 68 2e 80 00 	movl   $0x802e68,(%esp)
  801173:	e8 c4 f0 ff ff       	call   80023c <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  801178:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80117b:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80117e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801181:	89 ec                	mov    %ebp,%esp
  801183:	5d                   	pop    %ebp
  801184:	c3                   	ret    

00801185 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  801185:	55                   	push   %ebp
  801186:	89 e5                	mov    %esp,%ebp
  801188:	83 ec 0c             	sub    $0xc,%esp
  80118b:	89 1c 24             	mov    %ebx,(%esp)
  80118e:	89 74 24 04          	mov    %esi,0x4(%esp)
  801192:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801196:	ba 00 00 00 00       	mov    $0x0,%edx
  80119b:	b8 0b 00 00 00       	mov    $0xb,%eax
  8011a0:	89 d1                	mov    %edx,%ecx
  8011a2:	89 d3                	mov    %edx,%ebx
  8011a4:	89 d7                	mov    %edx,%edi
  8011a6:	89 d6                	mov    %edx,%esi
  8011a8:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  8011aa:	8b 1c 24             	mov    (%esp),%ebx
  8011ad:	8b 74 24 04          	mov    0x4(%esp),%esi
  8011b1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8011b5:	89 ec                	mov    %ebp,%esp
  8011b7:	5d                   	pop    %ebp
  8011b8:	c3                   	ret    

008011b9 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  8011b9:	55                   	push   %ebp
  8011ba:	89 e5                	mov    %esp,%ebp
  8011bc:	83 ec 0c             	sub    $0xc,%esp
  8011bf:	89 1c 24             	mov    %ebx,(%esp)
  8011c2:	89 74 24 04          	mov    %esi,0x4(%esp)
  8011c6:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011ca:	ba 00 00 00 00       	mov    $0x0,%edx
  8011cf:	b8 02 00 00 00       	mov    $0x2,%eax
  8011d4:	89 d1                	mov    %edx,%ecx
  8011d6:	89 d3                	mov    %edx,%ebx
  8011d8:	89 d7                	mov    %edx,%edi
  8011da:	89 d6                	mov    %edx,%esi
  8011dc:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  8011de:	8b 1c 24             	mov    (%esp),%ebx
  8011e1:	8b 74 24 04          	mov    0x4(%esp),%esi
  8011e5:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8011e9:	89 ec                	mov    %ebp,%esp
  8011eb:	5d                   	pop    %ebp
  8011ec:	c3                   	ret    

008011ed <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  8011ed:	55                   	push   %ebp
  8011ee:	89 e5                	mov    %esp,%ebp
  8011f0:	83 ec 38             	sub    $0x38,%esp
  8011f3:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8011f6:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8011f9:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011fc:	b9 00 00 00 00       	mov    $0x0,%ecx
  801201:	b8 03 00 00 00       	mov    $0x3,%eax
  801206:	8b 55 08             	mov    0x8(%ebp),%edx
  801209:	89 cb                	mov    %ecx,%ebx
  80120b:	89 cf                	mov    %ecx,%edi
  80120d:	89 ce                	mov    %ecx,%esi
  80120f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801211:	85 c0                	test   %eax,%eax
  801213:	7e 28                	jle    80123d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  801215:	89 44 24 10          	mov    %eax,0x10(%esp)
  801219:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  801220:	00 
  801221:	c7 44 24 08 4b 2e 80 	movl   $0x802e4b,0x8(%esp)
  801228:	00 
  801229:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801230:	00 
  801231:	c7 04 24 68 2e 80 00 	movl   $0x802e68,(%esp)
  801238:	e8 ff ef ff ff       	call   80023c <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80123d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801240:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801243:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801246:	89 ec                	mov    %ebp,%esp
  801248:	5d                   	pop    %ebp
  801249:	c3                   	ret    
  80124a:	00 00                	add    %al,(%eax)
  80124c:	00 00                	add    %al,(%eax)
	...

00801250 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801250:	55                   	push   %ebp
  801251:	89 e5                	mov    %esp,%ebp
  801253:	8b 45 08             	mov    0x8(%ebp),%eax
  801256:	05 00 00 00 30       	add    $0x30000000,%eax
  80125b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  80125e:	5d                   	pop    %ebp
  80125f:	c3                   	ret    

00801260 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801260:	55                   	push   %ebp
  801261:	89 e5                	mov    %esp,%ebp
  801263:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801266:	8b 45 08             	mov    0x8(%ebp),%eax
  801269:	89 04 24             	mov    %eax,(%esp)
  80126c:	e8 df ff ff ff       	call   801250 <fd2num>
  801271:	05 20 00 0d 00       	add    $0xd0020,%eax
  801276:	c1 e0 0c             	shl    $0xc,%eax
}
  801279:	c9                   	leave  
  80127a:	c3                   	ret    

0080127b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80127b:	55                   	push   %ebp
  80127c:	89 e5                	mov    %esp,%ebp
  80127e:	57                   	push   %edi
  80127f:	56                   	push   %esi
  801280:	53                   	push   %ebx
  801281:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  801284:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  801289:	a8 01                	test   $0x1,%al
  80128b:	74 36                	je     8012c3 <fd_alloc+0x48>
  80128d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  801292:	a8 01                	test   $0x1,%al
  801294:	74 2d                	je     8012c3 <fd_alloc+0x48>
  801296:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  80129b:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  8012a0:	be 00 00 40 ef       	mov    $0xef400000,%esi
  8012a5:	89 c3                	mov    %eax,%ebx
  8012a7:	89 c2                	mov    %eax,%edx
  8012a9:	c1 ea 16             	shr    $0x16,%edx
  8012ac:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  8012af:	f6 c2 01             	test   $0x1,%dl
  8012b2:	74 14                	je     8012c8 <fd_alloc+0x4d>
  8012b4:	89 c2                	mov    %eax,%edx
  8012b6:	c1 ea 0c             	shr    $0xc,%edx
  8012b9:	8b 14 96             	mov    (%esi,%edx,4),%edx
  8012bc:	f6 c2 01             	test   $0x1,%dl
  8012bf:	75 10                	jne    8012d1 <fd_alloc+0x56>
  8012c1:	eb 05                	jmp    8012c8 <fd_alloc+0x4d>
  8012c3:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  8012c8:	89 1f                	mov    %ebx,(%edi)
  8012ca:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  8012cf:	eb 17                	jmp    8012e8 <fd_alloc+0x6d>
  8012d1:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  8012d6:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  8012db:	75 c8                	jne    8012a5 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  8012dd:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  8012e3:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  8012e8:	5b                   	pop    %ebx
  8012e9:	5e                   	pop    %esi
  8012ea:	5f                   	pop    %edi
  8012eb:	5d                   	pop    %ebp
  8012ec:	c3                   	ret    

008012ed <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  8012ed:	55                   	push   %ebp
  8012ee:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  8012f0:	8b 45 08             	mov    0x8(%ebp),%eax
  8012f3:	83 f8 1f             	cmp    $0x1f,%eax
  8012f6:	77 36                	ja     80132e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  8012f8:	05 00 00 0d 00       	add    $0xd0000,%eax
  8012fd:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  801300:	89 c2                	mov    %eax,%edx
  801302:	c1 ea 16             	shr    $0x16,%edx
  801305:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  80130c:	f6 c2 01             	test   $0x1,%dl
  80130f:	74 1d                	je     80132e <fd_lookup+0x41>
  801311:	89 c2                	mov    %eax,%edx
  801313:	c1 ea 0c             	shr    $0xc,%edx
  801316:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  80131d:	f6 c2 01             	test   $0x1,%dl
  801320:	74 0c                	je     80132e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  801322:	8b 55 0c             	mov    0xc(%ebp),%edx
  801325:	89 02                	mov    %eax,(%edx)
  801327:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  80132c:	eb 05                	jmp    801333 <fd_lookup+0x46>
  80132e:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801333:	5d                   	pop    %ebp
  801334:	c3                   	ret    

00801335 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  801335:	55                   	push   %ebp
  801336:	89 e5                	mov    %esp,%ebp
  801338:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80133b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  80133e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801342:	8b 45 08             	mov    0x8(%ebp),%eax
  801345:	89 04 24             	mov    %eax,(%esp)
  801348:	e8 a0 ff ff ff       	call   8012ed <fd_lookup>
  80134d:	85 c0                	test   %eax,%eax
  80134f:	78 0e                	js     80135f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  801351:	8b 45 fc             	mov    -0x4(%ebp),%eax
  801354:	8b 55 0c             	mov    0xc(%ebp),%edx
  801357:	89 50 04             	mov    %edx,0x4(%eax)
  80135a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  80135f:	c9                   	leave  
  801360:	c3                   	ret    

00801361 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801361:	55                   	push   %ebp
  801362:	89 e5                	mov    %esp,%ebp
  801364:	56                   	push   %esi
  801365:	53                   	push   %ebx
  801366:	83 ec 10             	sub    $0x10,%esp
  801369:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80136c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80136f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  801374:	b8 08 60 80 00       	mov    $0x806008,%eax
  801379:	39 0d 08 60 80 00    	cmp    %ecx,0x806008
  80137f:	75 11                	jne    801392 <dev_lookup+0x31>
  801381:	eb 04                	jmp    801387 <dev_lookup+0x26>
  801383:	39 08                	cmp    %ecx,(%eax)
  801385:	75 10                	jne    801397 <dev_lookup+0x36>
			*dev = devtab[i];
  801387:	89 03                	mov    %eax,(%ebx)
  801389:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80138e:	66 90                	xchg   %ax,%ax
  801390:	eb 36                	jmp    8013c8 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  801392:	be f4 2e 80 00       	mov    $0x802ef4,%esi
  801397:	83 c2 01             	add    $0x1,%edx
  80139a:	8b 04 96             	mov    (%esi,%edx,4),%eax
  80139d:	85 c0                	test   %eax,%eax
  80139f:	75 e2                	jne    801383 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  8013a1:	a1 7c 60 80 00       	mov    0x80607c,%eax
  8013a6:	8b 40 4c             	mov    0x4c(%eax),%eax
  8013a9:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8013ad:	89 44 24 04          	mov    %eax,0x4(%esp)
  8013b1:	c7 04 24 78 2e 80 00 	movl   $0x802e78,(%esp)
  8013b8:	e8 44 ef ff ff       	call   800301 <cprintf>
	*dev = 0;
  8013bd:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  8013c3:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  8013c8:	83 c4 10             	add    $0x10,%esp
  8013cb:	5b                   	pop    %ebx
  8013cc:	5e                   	pop    %esi
  8013cd:	5d                   	pop    %ebp
  8013ce:	c3                   	ret    

008013cf <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  8013cf:	55                   	push   %ebp
  8013d0:	89 e5                	mov    %esp,%ebp
  8013d2:	53                   	push   %ebx
  8013d3:	83 ec 24             	sub    $0x24,%esp
  8013d6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8013d9:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8013dc:	89 44 24 04          	mov    %eax,0x4(%esp)
  8013e0:	8b 45 08             	mov    0x8(%ebp),%eax
  8013e3:	89 04 24             	mov    %eax,(%esp)
  8013e6:	e8 02 ff ff ff       	call   8012ed <fd_lookup>
  8013eb:	85 c0                	test   %eax,%eax
  8013ed:	78 53                	js     801442 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8013ef:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8013f2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8013f6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8013f9:	8b 00                	mov    (%eax),%eax
  8013fb:	89 04 24             	mov    %eax,(%esp)
  8013fe:	e8 5e ff ff ff       	call   801361 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801403:	85 c0                	test   %eax,%eax
  801405:	78 3b                	js     801442 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  801407:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80140c:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80140f:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  801413:	74 2d                	je     801442 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  801415:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  801418:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  80141f:	00 00 00 
	stat->st_isdir = 0;
  801422:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801429:	00 00 00 
	stat->st_dev = dev;
  80142c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80142f:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801435:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801439:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80143c:	89 14 24             	mov    %edx,(%esp)
  80143f:	ff 50 14             	call   *0x14(%eax)
}
  801442:	83 c4 24             	add    $0x24,%esp
  801445:	5b                   	pop    %ebx
  801446:	5d                   	pop    %ebp
  801447:	c3                   	ret    

00801448 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  801448:	55                   	push   %ebp
  801449:	89 e5                	mov    %esp,%ebp
  80144b:	53                   	push   %ebx
  80144c:	83 ec 24             	sub    $0x24,%esp
  80144f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801452:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801455:	89 44 24 04          	mov    %eax,0x4(%esp)
  801459:	89 1c 24             	mov    %ebx,(%esp)
  80145c:	e8 8c fe ff ff       	call   8012ed <fd_lookup>
  801461:	85 c0                	test   %eax,%eax
  801463:	78 5f                	js     8014c4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801465:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801468:	89 44 24 04          	mov    %eax,0x4(%esp)
  80146c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80146f:	8b 00                	mov    (%eax),%eax
  801471:	89 04 24             	mov    %eax,(%esp)
  801474:	e8 e8 fe ff ff       	call   801361 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801479:	85 c0                	test   %eax,%eax
  80147b:	78 47                	js     8014c4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80147d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801480:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801484:	75 23                	jne    8014a9 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  801486:	a1 7c 60 80 00       	mov    0x80607c,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  80148b:	8b 40 4c             	mov    0x4c(%eax),%eax
  80148e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801492:	89 44 24 04          	mov    %eax,0x4(%esp)
  801496:	c7 04 24 98 2e 80 00 	movl   $0x802e98,(%esp)
  80149d:	e8 5f ee ff ff       	call   800301 <cprintf>
  8014a2:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  8014a7:	eb 1b                	jmp    8014c4 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  8014a9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8014ac:	8b 48 18             	mov    0x18(%eax),%ecx
  8014af:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8014b4:	85 c9                	test   %ecx,%ecx
  8014b6:	74 0c                	je     8014c4 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  8014b8:	8b 45 0c             	mov    0xc(%ebp),%eax
  8014bb:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014bf:	89 14 24             	mov    %edx,(%esp)
  8014c2:	ff d1                	call   *%ecx
}
  8014c4:	83 c4 24             	add    $0x24,%esp
  8014c7:	5b                   	pop    %ebx
  8014c8:	5d                   	pop    %ebp
  8014c9:	c3                   	ret    

008014ca <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  8014ca:	55                   	push   %ebp
  8014cb:	89 e5                	mov    %esp,%ebp
  8014cd:	53                   	push   %ebx
  8014ce:	83 ec 24             	sub    $0x24,%esp
  8014d1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8014d4:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8014d7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014db:	89 1c 24             	mov    %ebx,(%esp)
  8014de:	e8 0a fe ff ff       	call   8012ed <fd_lookup>
  8014e3:	85 c0                	test   %eax,%eax
  8014e5:	78 66                	js     80154d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8014e7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8014ea:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014ee:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8014f1:	8b 00                	mov    (%eax),%eax
  8014f3:	89 04 24             	mov    %eax,(%esp)
  8014f6:	e8 66 fe ff ff       	call   801361 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8014fb:	85 c0                	test   %eax,%eax
  8014fd:	78 4e                	js     80154d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  8014ff:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801502:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801506:	75 23                	jne    80152b <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  801508:	a1 7c 60 80 00       	mov    0x80607c,%eax
  80150d:	8b 40 4c             	mov    0x4c(%eax),%eax
  801510:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801514:	89 44 24 04          	mov    %eax,0x4(%esp)
  801518:	c7 04 24 b9 2e 80 00 	movl   $0x802eb9,(%esp)
  80151f:	e8 dd ed ff ff       	call   800301 <cprintf>
  801524:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801529:	eb 22                	jmp    80154d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  80152b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80152e:	8b 48 0c             	mov    0xc(%eax),%ecx
  801531:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801536:	85 c9                	test   %ecx,%ecx
  801538:	74 13                	je     80154d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  80153a:	8b 45 10             	mov    0x10(%ebp),%eax
  80153d:	89 44 24 08          	mov    %eax,0x8(%esp)
  801541:	8b 45 0c             	mov    0xc(%ebp),%eax
  801544:	89 44 24 04          	mov    %eax,0x4(%esp)
  801548:	89 14 24             	mov    %edx,(%esp)
  80154b:	ff d1                	call   *%ecx
}
  80154d:	83 c4 24             	add    $0x24,%esp
  801550:	5b                   	pop    %ebx
  801551:	5d                   	pop    %ebp
  801552:	c3                   	ret    

00801553 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801553:	55                   	push   %ebp
  801554:	89 e5                	mov    %esp,%ebp
  801556:	57                   	push   %edi
  801557:	56                   	push   %esi
  801558:	53                   	push   %ebx
  801559:	83 ec 2c             	sub    $0x2c,%esp
  80155c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80155f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801562:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801565:	89 44 24 04          	mov    %eax,0x4(%esp)
  801569:	89 1c 24             	mov    %ebx,(%esp)
  80156c:	e8 7c fd ff ff       	call   8012ed <fd_lookup>
  801571:	85 c0                	test   %eax,%eax
  801573:	0f 88 b0 00 00 00    	js     801629 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801579:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80157c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801580:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801583:	8b 00                	mov    (%eax),%eax
  801585:	89 04 24             	mov    %eax,(%esp)
  801588:	e8 d4 fd ff ff       	call   801361 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80158d:	85 c0                	test   %eax,%eax
  80158f:	0f 88 94 00 00 00    	js     801629 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801595:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801598:	8b 40 08             	mov    0x8(%eax),%eax
  80159b:	83 e0 03             	and    $0x3,%eax
  80159e:	83 f8 01             	cmp    $0x1,%eax
  8015a1:	75 23                	jne    8015c6 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  8015a3:	a1 7c 60 80 00       	mov    0x80607c,%eax
  8015a8:	8b 40 4c             	mov    0x4c(%eax),%eax
  8015ab:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8015af:	89 44 24 04          	mov    %eax,0x4(%esp)
  8015b3:	c7 04 24 d6 2e 80 00 	movl   $0x802ed6,(%esp)
  8015ba:	e8 42 ed ff ff       	call   800301 <cprintf>
  8015bf:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  8015c4:	eb 63                	jmp    801629 <read+0xd6>
	}
	if (!dev->dev_read)
  8015c6:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8015cb:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8015ce:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  8015d2:	74 55                	je     801629 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8015d4:	ba 00 00 00 00       	mov    $0x0,%edx
  8015d9:	bb 00 00 00 00       	mov    $0x0,%ebx
  8015de:	b8 00 00 00 00       	mov    $0x0,%eax
  8015e3:	85 f6                	test   %esi,%esi
  8015e5:	74 42                	je     801629 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  8015e7:	bf 00 10 00 00       	mov    $0x1000,%edi
  8015ec:	89 f0                	mov    %esi,%eax
  8015ee:	29 d0                	sub    %edx,%eax
  8015f0:	89 c1                	mov    %eax,%ecx
  8015f2:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  8015f8:	3d 00 10 00 00       	cmp    $0x1000,%eax
  8015fd:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  801600:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801604:	03 55 0c             	add    0xc(%ebp),%edx
  801607:	89 54 24 04          	mov    %edx,0x4(%esp)
  80160b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80160e:	89 04 24             	mov    %eax,(%esp)
  801611:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801614:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  801617:	85 c0                	test   %eax,%eax
  801619:	78 0e                	js     801629 <read+0xd6>
			return m;
		if (m == 0)
  80161b:	85 c0                	test   %eax,%eax
  80161d:	74 08                	je     801627 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  80161f:	01 c3                	add    %eax,%ebx
  801621:	89 da                	mov    %ebx,%edx
  801623:	39 f3                	cmp    %esi,%ebx
  801625:	72 c5                	jb     8015ec <read+0x99>
  801627:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801629:	83 c4 2c             	add    $0x2c,%esp
  80162c:	5b                   	pop    %ebx
  80162d:	5e                   	pop    %esi
  80162e:	5f                   	pop    %edi
  80162f:	5d                   	pop    %ebp
  801630:	c3                   	ret    

00801631 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801631:	55                   	push   %ebp
  801632:	89 e5                	mov    %esp,%ebp
  801634:	57                   	push   %edi
  801635:	56                   	push   %esi
  801636:	53                   	push   %ebx
  801637:	83 ec 1c             	sub    $0x1c,%esp
  80163a:	8b 7d 08             	mov    0x8(%ebp),%edi
  80163d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801640:	ba 00 00 00 00       	mov    $0x0,%edx
  801645:	bb 00 00 00 00       	mov    $0x0,%ebx
  80164a:	b8 00 00 00 00       	mov    $0x0,%eax
  80164f:	85 f6                	test   %esi,%esi
  801651:	74 29                	je     80167c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801653:	89 f0                	mov    %esi,%eax
  801655:	29 d0                	sub    %edx,%eax
  801657:	89 44 24 08          	mov    %eax,0x8(%esp)
  80165b:	03 55 0c             	add    0xc(%ebp),%edx
  80165e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801662:	89 3c 24             	mov    %edi,(%esp)
  801665:	e8 e9 fe ff ff       	call   801553 <read>
		if (m < 0)
  80166a:	85 c0                	test   %eax,%eax
  80166c:	78 0e                	js     80167c <readn+0x4b>
			return m;
		if (m == 0)
  80166e:	85 c0                	test   %eax,%eax
  801670:	74 08                	je     80167a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801672:	01 c3                	add    %eax,%ebx
  801674:	89 da                	mov    %ebx,%edx
  801676:	39 f3                	cmp    %esi,%ebx
  801678:	72 d9                	jb     801653 <readn+0x22>
  80167a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  80167c:	83 c4 1c             	add    $0x1c,%esp
  80167f:	5b                   	pop    %ebx
  801680:	5e                   	pop    %esi
  801681:	5f                   	pop    %edi
  801682:	5d                   	pop    %ebp
  801683:	c3                   	ret    

00801684 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801684:	55                   	push   %ebp
  801685:	89 e5                	mov    %esp,%ebp
  801687:	83 ec 28             	sub    $0x28,%esp
  80168a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  80168d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801690:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801693:	89 34 24             	mov    %esi,(%esp)
  801696:	e8 b5 fb ff ff       	call   801250 <fd2num>
  80169b:	8d 55 f4             	lea    -0xc(%ebp),%edx
  80169e:	89 54 24 04          	mov    %edx,0x4(%esp)
  8016a2:	89 04 24             	mov    %eax,(%esp)
  8016a5:	e8 43 fc ff ff       	call   8012ed <fd_lookup>
  8016aa:	89 c3                	mov    %eax,%ebx
  8016ac:	85 c0                	test   %eax,%eax
  8016ae:	78 05                	js     8016b5 <fd_close+0x31>
  8016b0:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  8016b3:	74 0e                	je     8016c3 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  8016b5:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  8016b9:	b8 00 00 00 00       	mov    $0x0,%eax
  8016be:	0f 44 d8             	cmove  %eax,%ebx
  8016c1:	eb 3d                	jmp    801700 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  8016c3:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8016c6:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016ca:	8b 06                	mov    (%esi),%eax
  8016cc:	89 04 24             	mov    %eax,(%esp)
  8016cf:	e8 8d fc ff ff       	call   801361 <dev_lookup>
  8016d4:	89 c3                	mov    %eax,%ebx
  8016d6:	85 c0                	test   %eax,%eax
  8016d8:	78 16                	js     8016f0 <fd_close+0x6c>
		if (dev->dev_close)
  8016da:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8016dd:	8b 40 10             	mov    0x10(%eax),%eax
  8016e0:	bb 00 00 00 00       	mov    $0x0,%ebx
  8016e5:	85 c0                	test   %eax,%eax
  8016e7:	74 07                	je     8016f0 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  8016e9:	89 34 24             	mov    %esi,(%esp)
  8016ec:	ff d0                	call   *%eax
  8016ee:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  8016f0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8016f4:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8016fb:	e8 6a f9 ff ff       	call   80106a <sys_page_unmap>
	return r;
}
  801700:	89 d8                	mov    %ebx,%eax
  801702:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801705:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801708:	89 ec                	mov    %ebp,%esp
  80170a:	5d                   	pop    %ebp
  80170b:	c3                   	ret    

0080170c <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  80170c:	55                   	push   %ebp
  80170d:	89 e5                	mov    %esp,%ebp
  80170f:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801712:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801715:	89 44 24 04          	mov    %eax,0x4(%esp)
  801719:	8b 45 08             	mov    0x8(%ebp),%eax
  80171c:	89 04 24             	mov    %eax,(%esp)
  80171f:	e8 c9 fb ff ff       	call   8012ed <fd_lookup>
  801724:	85 c0                	test   %eax,%eax
  801726:	78 13                	js     80173b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  801728:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  80172f:	00 
  801730:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801733:	89 04 24             	mov    %eax,(%esp)
  801736:	e8 49 ff ff ff       	call   801684 <fd_close>
}
  80173b:	c9                   	leave  
  80173c:	c3                   	ret    

0080173d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  80173d:	55                   	push   %ebp
  80173e:	89 e5                	mov    %esp,%ebp
  801740:	83 ec 18             	sub    $0x18,%esp
  801743:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801746:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801749:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801750:	00 
  801751:	8b 45 08             	mov    0x8(%ebp),%eax
  801754:	89 04 24             	mov    %eax,(%esp)
  801757:	e8 80 03 00 00       	call   801adc <open>
  80175c:	89 c3                	mov    %eax,%ebx
  80175e:	85 c0                	test   %eax,%eax
  801760:	78 1b                	js     80177d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801762:	8b 45 0c             	mov    0xc(%ebp),%eax
  801765:	89 44 24 04          	mov    %eax,0x4(%esp)
  801769:	89 1c 24             	mov    %ebx,(%esp)
  80176c:	e8 5e fc ff ff       	call   8013cf <fstat>
  801771:	89 c6                	mov    %eax,%esi
	close(fd);
  801773:	89 1c 24             	mov    %ebx,(%esp)
  801776:	e8 91 ff ff ff       	call   80170c <close>
  80177b:	89 f3                	mov    %esi,%ebx
	return r;
}
  80177d:	89 d8                	mov    %ebx,%eax
  80177f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801782:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801785:	89 ec                	mov    %ebp,%esp
  801787:	5d                   	pop    %ebp
  801788:	c3                   	ret    

00801789 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801789:	55                   	push   %ebp
  80178a:	89 e5                	mov    %esp,%ebp
  80178c:	53                   	push   %ebx
  80178d:	83 ec 14             	sub    $0x14,%esp
  801790:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801795:	89 1c 24             	mov    %ebx,(%esp)
  801798:	e8 6f ff ff ff       	call   80170c <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  80179d:	83 c3 01             	add    $0x1,%ebx
  8017a0:	83 fb 20             	cmp    $0x20,%ebx
  8017a3:	75 f0                	jne    801795 <close_all+0xc>
		close(i);
}
  8017a5:	83 c4 14             	add    $0x14,%esp
  8017a8:	5b                   	pop    %ebx
  8017a9:	5d                   	pop    %ebp
  8017aa:	c3                   	ret    

008017ab <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  8017ab:	55                   	push   %ebp
  8017ac:	89 e5                	mov    %esp,%ebp
  8017ae:	83 ec 58             	sub    $0x58,%esp
  8017b1:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8017b4:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8017b7:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8017ba:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  8017bd:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8017c0:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017c4:	8b 45 08             	mov    0x8(%ebp),%eax
  8017c7:	89 04 24             	mov    %eax,(%esp)
  8017ca:	e8 1e fb ff ff       	call   8012ed <fd_lookup>
  8017cf:	89 c3                	mov    %eax,%ebx
  8017d1:	85 c0                	test   %eax,%eax
  8017d3:	0f 88 e0 00 00 00    	js     8018b9 <dup+0x10e>
		return r;
	close(newfdnum);
  8017d9:	89 3c 24             	mov    %edi,(%esp)
  8017dc:	e8 2b ff ff ff       	call   80170c <close>

	newfd = INDEX2FD(newfdnum);
  8017e1:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  8017e7:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  8017ea:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8017ed:	89 04 24             	mov    %eax,(%esp)
  8017f0:	e8 6b fa ff ff       	call   801260 <fd2data>
  8017f5:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  8017f7:	89 34 24             	mov    %esi,(%esp)
  8017fa:	e8 61 fa ff ff       	call   801260 <fd2data>
  8017ff:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  801802:	89 da                	mov    %ebx,%edx
  801804:	89 d8                	mov    %ebx,%eax
  801806:	c1 e8 16             	shr    $0x16,%eax
  801809:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801810:	a8 01                	test   $0x1,%al
  801812:	74 43                	je     801857 <dup+0xac>
  801814:	c1 ea 0c             	shr    $0xc,%edx
  801817:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  80181e:	a8 01                	test   $0x1,%al
  801820:	74 35                	je     801857 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  801822:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801829:	25 07 0e 00 00       	and    $0xe07,%eax
  80182e:	89 44 24 10          	mov    %eax,0x10(%esp)
  801832:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801835:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801839:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801840:	00 
  801841:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801845:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80184c:	e8 77 f8 ff ff       	call   8010c8 <sys_page_map>
  801851:	89 c3                	mov    %eax,%ebx
  801853:	85 c0                	test   %eax,%eax
  801855:	78 3f                	js     801896 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801857:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80185a:	89 c2                	mov    %eax,%edx
  80185c:	c1 ea 0c             	shr    $0xc,%edx
  80185f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801866:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  80186c:	89 54 24 10          	mov    %edx,0x10(%esp)
  801870:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801874:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80187b:	00 
  80187c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801880:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801887:	e8 3c f8 ff ff       	call   8010c8 <sys_page_map>
  80188c:	89 c3                	mov    %eax,%ebx
  80188e:	85 c0                	test   %eax,%eax
  801890:	78 04                	js     801896 <dup+0xeb>
  801892:	89 fb                	mov    %edi,%ebx
  801894:	eb 23                	jmp    8018b9 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801896:	89 74 24 04          	mov    %esi,0x4(%esp)
  80189a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8018a1:	e8 c4 f7 ff ff       	call   80106a <sys_page_unmap>
	sys_page_unmap(0, nva);
  8018a6:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8018a9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018ad:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8018b4:	e8 b1 f7 ff ff       	call   80106a <sys_page_unmap>
	return r;
}
  8018b9:	89 d8                	mov    %ebx,%eax
  8018bb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8018be:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8018c1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8018c4:	89 ec                	mov    %ebp,%esp
  8018c6:	5d                   	pop    %ebp
  8018c7:	c3                   	ret    

008018c8 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  8018c8:	55                   	push   %ebp
  8018c9:	89 e5                	mov    %esp,%ebp
  8018cb:	53                   	push   %ebx
  8018cc:	83 ec 14             	sub    $0x14,%esp
  8018cf:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  8018d1:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  8018d7:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8018de:	00 
  8018df:	c7 44 24 08 00 30 80 	movl   $0x803000,0x8(%esp)
  8018e6:	00 
  8018e7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018eb:	89 14 24             	mov    %edx,(%esp)
  8018ee:	e8 2d 0e 00 00       	call   802720 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  8018f3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8018fa:	00 
  8018fb:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8018ff:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801906:	e8 87 0e 00 00       	call   802792 <ipc_recv>
}
  80190b:	83 c4 14             	add    $0x14,%esp
  80190e:	5b                   	pop    %ebx
  80190f:	5d                   	pop    %ebp
  801910:	c3                   	ret    

00801911 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  801911:	55                   	push   %ebp
  801912:	89 e5                	mov    %esp,%ebp
  801914:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801917:	8b 45 08             	mov    0x8(%ebp),%eax
  80191a:	8b 40 0c             	mov    0xc(%eax),%eax
  80191d:	a3 00 30 80 00       	mov    %eax,0x803000
	fsipcbuf.set_size.req_size = newsize;
  801922:	8b 45 0c             	mov    0xc(%ebp),%eax
  801925:	a3 04 30 80 00       	mov    %eax,0x803004
	return fsipc(FSREQ_SET_SIZE, NULL);
  80192a:	ba 00 00 00 00       	mov    $0x0,%edx
  80192f:	b8 02 00 00 00       	mov    $0x2,%eax
  801934:	e8 8f ff ff ff       	call   8018c8 <fsipc>
}
  801939:	c9                   	leave  
  80193a:	c3                   	ret    

0080193b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  80193b:	55                   	push   %ebp
  80193c:	89 e5                	mov    %esp,%ebp
  80193e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801941:	8b 45 08             	mov    0x8(%ebp),%eax
  801944:	8b 40 0c             	mov    0xc(%eax),%eax
  801947:	a3 00 30 80 00       	mov    %eax,0x803000
	return fsipc(FSREQ_FLUSH, NULL);
  80194c:	ba 00 00 00 00       	mov    $0x0,%edx
  801951:	b8 06 00 00 00       	mov    $0x6,%eax
  801956:	e8 6d ff ff ff       	call   8018c8 <fsipc>
}
  80195b:	c9                   	leave  
  80195c:	c3                   	ret    

0080195d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  80195d:	55                   	push   %ebp
  80195e:	89 e5                	mov    %esp,%ebp
  801960:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801963:	ba 00 00 00 00       	mov    $0x0,%edx
  801968:	b8 08 00 00 00       	mov    $0x8,%eax
  80196d:	e8 56 ff ff ff       	call   8018c8 <fsipc>
}
  801972:	c9                   	leave  
  801973:	c3                   	ret    

00801974 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801974:	55                   	push   %ebp
  801975:	89 e5                	mov    %esp,%ebp
  801977:	53                   	push   %ebx
  801978:	83 ec 14             	sub    $0x14,%esp
  80197b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  80197e:	8b 45 08             	mov    0x8(%ebp),%eax
  801981:	8b 40 0c             	mov    0xc(%eax),%eax
  801984:	a3 00 30 80 00       	mov    %eax,0x803000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801989:	ba 00 00 00 00       	mov    $0x0,%edx
  80198e:	b8 05 00 00 00       	mov    $0x5,%eax
  801993:	e8 30 ff ff ff       	call   8018c8 <fsipc>
  801998:	85 c0                	test   %eax,%eax
  80199a:	78 2b                	js     8019c7 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  80199c:	c7 44 24 04 00 30 80 	movl   $0x803000,0x4(%esp)
  8019a3:	00 
  8019a4:	89 1c 24             	mov    %ebx,(%esp)
  8019a7:	e8 1e f0 ff ff       	call   8009ca <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  8019ac:	a1 80 30 80 00       	mov    0x803080,%eax
  8019b1:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  8019b7:	a1 84 30 80 00       	mov    0x803084,%eax
  8019bc:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  8019c2:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  8019c7:	83 c4 14             	add    $0x14,%esp
  8019ca:	5b                   	pop    %ebx
  8019cb:	5d                   	pop    %ebp
  8019cc:	c3                   	ret    

008019cd <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  8019cd:	55                   	push   %ebp
  8019ce:	89 e5                	mov    %esp,%ebp
  8019d0:	53                   	push   %ebx
  8019d1:	83 ec 14             	sub    $0x14,%esp
  8019d4:	8b 45 08             	mov    0x8(%ebp),%eax
  8019d7:	8b 55 0c             	mov    0xc(%ebp),%edx
  8019da:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  8019dd:	85 c0                	test   %eax,%eax
  8019df:	74 44                	je     801a25 <devfile_write+0x58>
  8019e1:	85 d2                	test   %edx,%edx
  8019e3:	74 40                	je     801a25 <devfile_write+0x58>
  8019e5:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  8019eb:	77 38                	ja     801a25 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  8019ed:	8b 40 0c             	mov    0xc(%eax),%eax
  8019f0:	a3 00 30 80 00       	mov    %eax,0x803000
    fsipcbuf.write.req_n        = n;
  8019f5:	89 1d 04 30 80 00    	mov    %ebx,0x803004
    memmove(fsipcbuf.write.req_buf, buf, n);
  8019fb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8019ff:	89 54 24 04          	mov    %edx,0x4(%esp)
  801a03:	c7 04 24 08 30 80 00 	movl   $0x803008,(%esp)
  801a0a:	e8 76 f1 ff ff       	call   800b85 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  801a0f:	ba 00 00 00 00       	mov    $0x0,%edx
  801a14:	b8 04 00 00 00       	mov    $0x4,%eax
  801a19:	e8 aa fe ff ff       	call   8018c8 <fsipc>
        return r;
    return n;
  801a1e:	85 c0                	test   %eax,%eax
  801a20:	0f 49 c3             	cmovns %ebx,%eax
  801a23:	eb 05                	jmp    801a2a <devfile_write+0x5d>
  801a25:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801a2a:	83 c4 14             	add    $0x14,%esp
  801a2d:	5b                   	pop    %ebx
  801a2e:	5d                   	pop    %ebp
  801a2f:	c3                   	ret    

00801a30 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  801a30:	55                   	push   %ebp
  801a31:	89 e5                	mov    %esp,%ebp
  801a33:	83 ec 18             	sub    $0x18,%esp
  801a36:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801a39:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801a3c:	8b 45 08             	mov    0x8(%ebp),%eax
  801a3f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  801a42:	85 c0                	test   %eax,%eax
  801a44:	74 04                	je     801a4a <devfile_read+0x1a>
  801a46:	85 f6                	test   %esi,%esi
  801a48:	75 07                	jne    801a51 <devfile_read+0x21>
  801a4a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801a4f:	eb 39                	jmp    801a8a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  801a51:	8b 40 0c             	mov    0xc(%eax),%eax
  801a54:	a3 00 30 80 00       	mov    %eax,0x803000
  fsipcbuf.read.req_n         = n;
  801a59:	8b 45 10             	mov    0x10(%ebp),%eax
  801a5c:	a3 04 30 80 00       	mov    %eax,0x803004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  801a61:	ba 00 00 00 00       	mov    $0x0,%edx
  801a66:	b8 03 00 00 00       	mov    $0x3,%eax
  801a6b:	e8 58 fe ff ff       	call   8018c8 <fsipc>
  801a70:	89 c3                	mov    %eax,%ebx
  801a72:	85 c0                	test   %eax,%eax
  801a74:	78 14                	js     801a8a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801a76:	89 44 24 08          	mov    %eax,0x8(%esp)
  801a7a:	c7 44 24 04 00 30 80 	movl   $0x803000,0x4(%esp)
  801a81:	00 
  801a82:	89 34 24             	mov    %esi,(%esp)
  801a85:	e8 fb f0 ff ff       	call   800b85 <memmove>
  return r;
}
  801a8a:	89 d8                	mov    %ebx,%eax
  801a8c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801a8f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801a92:	89 ec                	mov    %ebp,%esp
  801a94:	5d                   	pop    %ebp
  801a95:	c3                   	ret    

00801a96 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  801a96:	55                   	push   %ebp
  801a97:	89 e5                	mov    %esp,%ebp
  801a99:	53                   	push   %ebx
  801a9a:	83 ec 14             	sub    $0x14,%esp
  801a9d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  801aa0:	89 1c 24             	mov    %ebx,(%esp)
  801aa3:	e8 d8 ee ff ff       	call   800980 <strlen>
  801aa8:	89 c2                	mov    %eax,%edx
  801aaa:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  801aaf:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  801ab5:	7f 1f                	jg     801ad6 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  801ab7:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801abb:	c7 04 24 00 30 80 00 	movl   $0x803000,(%esp)
  801ac2:	e8 03 ef ff ff       	call   8009ca <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  801ac7:	ba 00 00 00 00       	mov    $0x0,%edx
  801acc:	b8 07 00 00 00       	mov    $0x7,%eax
  801ad1:	e8 f2 fd ff ff       	call   8018c8 <fsipc>
}
  801ad6:	83 c4 14             	add    $0x14,%esp
  801ad9:	5b                   	pop    %ebx
  801ada:	5d                   	pop    %ebp
  801adb:	c3                   	ret    

00801adc <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  801adc:	55                   	push   %ebp
  801add:	89 e5                	mov    %esp,%ebp
  801adf:	83 ec 28             	sub    $0x28,%esp
  801ae2:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801ae5:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801ae8:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  801aeb:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801af0:	85 f6                	test   %esi,%esi
  801af2:	74 65                	je     801b59 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  801af4:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  801afb:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801afe:	89 04 24             	mov    %eax,(%esp)
  801b01:	e8 75 f7 ff ff       	call   80127b <fd_alloc>
  801b06:	89 c3                	mov    %eax,%ebx
  801b08:	85 c0                	test   %eax,%eax
  801b0a:	78 4d                	js     801b59 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  801b0c:	89 74 24 04          	mov    %esi,0x4(%esp)
  801b10:	c7 04 24 00 30 80 00 	movl   $0x803000,(%esp)
  801b17:	e8 ae ee ff ff       	call   8009ca <strcpy>
	fsipcbuf.open.req_omode = mode;
  801b1c:	8b 45 0c             	mov    0xc(%ebp),%eax
  801b1f:	a3 00 34 80 00       	mov    %eax,0x803400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  801b24:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801b27:	b8 01 00 00 00       	mov    $0x1,%eax
  801b2c:	e8 97 fd ff ff       	call   8018c8 <fsipc>
  801b31:	89 c3                	mov    %eax,%ebx
  801b33:	85 c0                	test   %eax,%eax
  801b35:	79 15                	jns    801b4c <open+0x70>
    fd_close(f, 0);
  801b37:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801b3e:	00 
  801b3f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801b42:	89 04 24             	mov    %eax,(%esp)
  801b45:	e8 3a fb ff ff       	call   801684 <fd_close>
    return r;
  801b4a:	eb 0d                	jmp    801b59 <open+0x7d>
  }
  return fd2num(f);
  801b4c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801b4f:	89 04 24             	mov    %eax,(%esp)
  801b52:	e8 f9 f6 ff ff       	call   801250 <fd2num>
  801b57:	89 c3                	mov    %eax,%ebx
}
  801b59:	89 d8                	mov    %ebx,%eax
  801b5b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801b5e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801b61:	89 ec                	mov    %ebp,%esp
  801b63:	5d                   	pop    %ebp
  801b64:	c3                   	ret    
  801b65:	00 00                	add    %al,(%eax)
	...

00801b68 <writebuf>:
};


static void
writebuf(struct printbuf *b)
{
  801b68:	55                   	push   %ebp
  801b69:	89 e5                	mov    %esp,%ebp
  801b6b:	53                   	push   %ebx
  801b6c:	83 ec 14             	sub    $0x14,%esp
  801b6f:	89 c3                	mov    %eax,%ebx
	if (b->error > 0) {
  801b71:	83 78 0c 00          	cmpl   $0x0,0xc(%eax)
  801b75:	7e 31                	jle    801ba8 <writebuf+0x40>
		ssize_t result = write(b->fd, b->buf, b->idx);
  801b77:	8b 40 04             	mov    0x4(%eax),%eax
  801b7a:	89 44 24 08          	mov    %eax,0x8(%esp)
  801b7e:	8d 43 10             	lea    0x10(%ebx),%eax
  801b81:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b85:	8b 03                	mov    (%ebx),%eax
  801b87:	89 04 24             	mov    %eax,(%esp)
  801b8a:	e8 3b f9 ff ff       	call   8014ca <write>
		if (result > 0)
  801b8f:	85 c0                	test   %eax,%eax
  801b91:	7e 03                	jle    801b96 <writebuf+0x2e>
			b->result += result;
  801b93:	01 43 08             	add    %eax,0x8(%ebx)
		if (result != b->idx) // error, or wrote less than supplied
  801b96:	3b 43 04             	cmp    0x4(%ebx),%eax
  801b99:	74 0d                	je     801ba8 <writebuf+0x40>
			b->error = (result < 0 ? result : 0);
  801b9b:	85 c0                	test   %eax,%eax
  801b9d:	ba 00 00 00 00       	mov    $0x0,%edx
  801ba2:	0f 4f c2             	cmovg  %edx,%eax
  801ba5:	89 43 0c             	mov    %eax,0xc(%ebx)
	}
}
  801ba8:	83 c4 14             	add    $0x14,%esp
  801bab:	5b                   	pop    %ebx
  801bac:	5d                   	pop    %ebp
  801bad:	c3                   	ret    

00801bae <vfprintf>:
	}
}

int
vfprintf(int fd, const char *fmt, va_list ap)
{
  801bae:	55                   	push   %ebp
  801baf:	89 e5                	mov    %esp,%ebp
  801bb1:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.fd = fd;
  801bb7:	8b 45 08             	mov    0x8(%ebp),%eax
  801bba:	89 85 e8 fe ff ff    	mov    %eax,-0x118(%ebp)
	b.idx = 0;
  801bc0:	c7 85 ec fe ff ff 00 	movl   $0x0,-0x114(%ebp)
  801bc7:	00 00 00 
	b.result = 0;
  801bca:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  801bd1:	00 00 00 
	b.error = 1;
  801bd4:	c7 85 f4 fe ff ff 01 	movl   $0x1,-0x10c(%ebp)
  801bdb:	00 00 00 
	vprintfmt(putch, &b, fmt, ap);
  801bde:	8b 45 10             	mov    0x10(%ebp),%eax
  801be1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801be5:	8b 45 0c             	mov    0xc(%ebp),%eax
  801be8:	89 44 24 08          	mov    %eax,0x8(%esp)
  801bec:	8d 85 e8 fe ff ff    	lea    -0x118(%ebp),%eax
  801bf2:	89 44 24 04          	mov    %eax,0x4(%esp)
  801bf6:	c7 04 24 6a 1c 80 00 	movl   $0x801c6a,(%esp)
  801bfd:	e8 ab e8 ff ff       	call   8004ad <vprintfmt>
	if (b.idx > 0)
  801c02:	83 bd ec fe ff ff 00 	cmpl   $0x0,-0x114(%ebp)
  801c09:	7e 0b                	jle    801c16 <vfprintf+0x68>
		writebuf(&b);
  801c0b:	8d 85 e8 fe ff ff    	lea    -0x118(%ebp),%eax
  801c11:	e8 52 ff ff ff       	call   801b68 <writebuf>

	return (b.result ? b.result : b.error);
  801c16:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  801c1c:	85 c0                	test   %eax,%eax
  801c1e:	0f 44 85 f4 fe ff ff 	cmove  -0x10c(%ebp),%eax
}
  801c25:	c9                   	leave  
  801c26:	c3                   	ret    

00801c27 <printf>:
	return cnt;
}

int
printf(const char *fmt, ...)
{
  801c27:	55                   	push   %ebp
  801c28:	89 e5                	mov    %esp,%ebp
  801c2a:	83 ec 18             	sub    $0x18,%esp

	return cnt;
}

int
printf(const char *fmt, ...)
  801c2d:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vfprintf(1, fmt, ap);
  801c30:	89 44 24 08          	mov    %eax,0x8(%esp)
  801c34:	8b 45 08             	mov    0x8(%ebp),%eax
  801c37:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c3b:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  801c42:	e8 67 ff ff ff       	call   801bae <vfprintf>
	va_end(ap);

	return cnt;
}
  801c47:	c9                   	leave  
  801c48:	c3                   	ret    

00801c49 <fprintf>:
	return (b.result ? b.result : b.error);
}

int
fprintf(int fd, const char *fmt, ...)
{
  801c49:	55                   	push   %ebp
  801c4a:	89 e5                	mov    %esp,%ebp
  801c4c:	83 ec 18             	sub    $0x18,%esp

	return (b.result ? b.result : b.error);
}

int
fprintf(int fd, const char *fmt, ...)
  801c4f:	8d 45 10             	lea    0x10(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vfprintf(fd, fmt, ap);
  801c52:	89 44 24 08          	mov    %eax,0x8(%esp)
  801c56:	8b 45 0c             	mov    0xc(%ebp),%eax
  801c59:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c5d:	8b 45 08             	mov    0x8(%ebp),%eax
  801c60:	89 04 24             	mov    %eax,(%esp)
  801c63:	e8 46 ff ff ff       	call   801bae <vfprintf>
	va_end(ap);

	return cnt;
}
  801c68:	c9                   	leave  
  801c69:	c3                   	ret    

00801c6a <putch>:
	}
}

static void
putch(int ch, void *thunk)
{
  801c6a:	55                   	push   %ebp
  801c6b:	89 e5                	mov    %esp,%ebp
  801c6d:	53                   	push   %ebx
  801c6e:	83 ec 04             	sub    $0x4,%esp
	struct printbuf *b = (struct printbuf *) thunk;
  801c71:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  801c74:	8b 43 04             	mov    0x4(%ebx),%eax
  801c77:	8b 55 08             	mov    0x8(%ebp),%edx
  801c7a:	88 54 03 10          	mov    %dl,0x10(%ebx,%eax,1)
  801c7e:	83 c0 01             	add    $0x1,%eax
  801c81:	89 43 04             	mov    %eax,0x4(%ebx)
	if (b->idx == 256) {
  801c84:	3d 00 01 00 00       	cmp    $0x100,%eax
  801c89:	75 0e                	jne    801c99 <putch+0x2f>
		writebuf(b);
  801c8b:	89 d8                	mov    %ebx,%eax
  801c8d:	e8 d6 fe ff ff       	call   801b68 <writebuf>
		b->idx = 0;
  801c92:	c7 43 04 00 00 00 00 	movl   $0x0,0x4(%ebx)
	}
}
  801c99:	83 c4 04             	add    $0x4,%esp
  801c9c:	5b                   	pop    %ebx
  801c9d:	5d                   	pop    %ebp
  801c9e:	c3                   	ret    
	...

00801ca0 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  801ca0:	55                   	push   %ebp
  801ca1:	89 e5                	mov    %esp,%ebp
  801ca3:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  801ca6:	c7 44 24 04 08 2f 80 	movl   $0x802f08,0x4(%esp)
  801cad:	00 
  801cae:	8b 45 0c             	mov    0xc(%ebp),%eax
  801cb1:	89 04 24             	mov    %eax,(%esp)
  801cb4:	e8 11 ed ff ff       	call   8009ca <strcpy>
	return 0;
}
  801cb9:	b8 00 00 00 00       	mov    $0x0,%eax
  801cbe:	c9                   	leave  
  801cbf:	c3                   	ret    

00801cc0 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  801cc0:	55                   	push   %ebp
  801cc1:	89 e5                	mov    %esp,%ebp
  801cc3:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  801cc6:	8b 45 08             	mov    0x8(%ebp),%eax
  801cc9:	8b 40 0c             	mov    0xc(%eax),%eax
  801ccc:	89 04 24             	mov    %eax,(%esp)
  801ccf:	e8 9d 02 00 00       	call   801f71 <nsipc_close>
}
  801cd4:	c9                   	leave  
  801cd5:	c3                   	ret    

00801cd6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  801cd6:	55                   	push   %ebp
  801cd7:	89 e5                	mov    %esp,%ebp
  801cd9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  801cdc:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801ce3:	00 
  801ce4:	8b 45 10             	mov    0x10(%ebp),%eax
  801ce7:	89 44 24 08          	mov    %eax,0x8(%esp)
  801ceb:	8b 45 0c             	mov    0xc(%ebp),%eax
  801cee:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cf2:	8b 45 08             	mov    0x8(%ebp),%eax
  801cf5:	8b 40 0c             	mov    0xc(%eax),%eax
  801cf8:	89 04 24             	mov    %eax,(%esp)
  801cfb:	e8 ad 02 00 00       	call   801fad <nsipc_send>
}
  801d00:	c9                   	leave  
  801d01:	c3                   	ret    

00801d02 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  801d02:	55                   	push   %ebp
  801d03:	89 e5                	mov    %esp,%ebp
  801d05:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  801d08:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801d0f:	00 
  801d10:	8b 45 10             	mov    0x10(%ebp),%eax
  801d13:	89 44 24 08          	mov    %eax,0x8(%esp)
  801d17:	8b 45 0c             	mov    0xc(%ebp),%eax
  801d1a:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d1e:	8b 45 08             	mov    0x8(%ebp),%eax
  801d21:	8b 40 0c             	mov    0xc(%eax),%eax
  801d24:	89 04 24             	mov    %eax,(%esp)
  801d27:	e8 f4 02 00 00       	call   802020 <nsipc_recv>
}
  801d2c:	c9                   	leave  
  801d2d:	c3                   	ret    

00801d2e <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  801d2e:	55                   	push   %ebp
  801d2f:	89 e5                	mov    %esp,%ebp
  801d31:	56                   	push   %esi
  801d32:	53                   	push   %ebx
  801d33:	83 ec 20             	sub    $0x20,%esp
  801d36:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801d38:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801d3b:	89 04 24             	mov    %eax,(%esp)
  801d3e:	e8 38 f5 ff ff       	call   80127b <fd_alloc>
  801d43:	89 c3                	mov    %eax,%ebx
  801d45:	85 c0                	test   %eax,%eax
  801d47:	78 21                	js     801d6a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  801d49:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  801d50:	00 
  801d51:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d54:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d58:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d5f:	e8 c2 f3 ff ff       	call   801126 <sys_page_alloc>
  801d64:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801d66:	85 c0                	test   %eax,%eax
  801d68:	79 0a                	jns    801d74 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  801d6a:	89 34 24             	mov    %esi,(%esp)
  801d6d:	e8 ff 01 00 00       	call   801f71 <nsipc_close>
		return r;
  801d72:	eb 28                	jmp    801d9c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  801d74:	8b 15 24 60 80 00    	mov    0x806024,%edx
  801d7a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d7d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  801d7f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d82:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  801d89:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d8c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  801d8f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d92:	89 04 24             	mov    %eax,(%esp)
  801d95:	e8 b6 f4 ff ff       	call   801250 <fd2num>
  801d9a:	89 c3                	mov    %eax,%ebx
}
  801d9c:	89 d8                	mov    %ebx,%eax
  801d9e:	83 c4 20             	add    $0x20,%esp
  801da1:	5b                   	pop    %ebx
  801da2:	5e                   	pop    %esi
  801da3:	5d                   	pop    %ebp
  801da4:	c3                   	ret    

00801da5 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  801da5:	55                   	push   %ebp
  801da6:	89 e5                	mov    %esp,%ebp
  801da8:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  801dab:	8b 45 10             	mov    0x10(%ebp),%eax
  801dae:	89 44 24 08          	mov    %eax,0x8(%esp)
  801db2:	8b 45 0c             	mov    0xc(%ebp),%eax
  801db5:	89 44 24 04          	mov    %eax,0x4(%esp)
  801db9:	8b 45 08             	mov    0x8(%ebp),%eax
  801dbc:	89 04 24             	mov    %eax,(%esp)
  801dbf:	e8 61 01 00 00       	call   801f25 <nsipc_socket>
  801dc4:	85 c0                	test   %eax,%eax
  801dc6:	78 05                	js     801dcd <socket+0x28>
		return r;
	return alloc_sockfd(r);
  801dc8:	e8 61 ff ff ff       	call   801d2e <alloc_sockfd>
}
  801dcd:	c9                   	leave  
  801dce:	66 90                	xchg   %ax,%ax
  801dd0:	c3                   	ret    

00801dd1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  801dd1:	55                   	push   %ebp
  801dd2:	89 e5                	mov    %esp,%ebp
  801dd4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  801dd7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801dda:	89 54 24 04          	mov    %edx,0x4(%esp)
  801dde:	89 04 24             	mov    %eax,(%esp)
  801de1:	e8 07 f5 ff ff       	call   8012ed <fd_lookup>
  801de6:	85 c0                	test   %eax,%eax
  801de8:	78 15                	js     801dff <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  801dea:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801ded:	8b 0a                	mov    (%edx),%ecx
  801def:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801df4:	3b 0d 24 60 80 00    	cmp    0x806024,%ecx
  801dfa:	75 03                	jne    801dff <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  801dfc:	8b 42 0c             	mov    0xc(%edx),%eax
}
  801dff:	c9                   	leave  
  801e00:	c3                   	ret    

00801e01 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  801e01:	55                   	push   %ebp
  801e02:	89 e5                	mov    %esp,%ebp
  801e04:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801e07:	8b 45 08             	mov    0x8(%ebp),%eax
  801e0a:	e8 c2 ff ff ff       	call   801dd1 <fd2sockid>
  801e0f:	85 c0                	test   %eax,%eax
  801e11:	78 0f                	js     801e22 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  801e13:	8b 55 0c             	mov    0xc(%ebp),%edx
  801e16:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e1a:	89 04 24             	mov    %eax,(%esp)
  801e1d:	e8 2d 01 00 00       	call   801f4f <nsipc_listen>
}
  801e22:	c9                   	leave  
  801e23:	c3                   	ret    

00801e24 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  801e24:	55                   	push   %ebp
  801e25:	89 e5                	mov    %esp,%ebp
  801e27:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801e2a:	8b 45 08             	mov    0x8(%ebp),%eax
  801e2d:	e8 9f ff ff ff       	call   801dd1 <fd2sockid>
  801e32:	85 c0                	test   %eax,%eax
  801e34:	78 16                	js     801e4c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  801e36:	8b 55 10             	mov    0x10(%ebp),%edx
  801e39:	89 54 24 08          	mov    %edx,0x8(%esp)
  801e3d:	8b 55 0c             	mov    0xc(%ebp),%edx
  801e40:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e44:	89 04 24             	mov    %eax,(%esp)
  801e47:	e8 54 02 00 00       	call   8020a0 <nsipc_connect>
}
  801e4c:	c9                   	leave  
  801e4d:	c3                   	ret    

00801e4e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  801e4e:	55                   	push   %ebp
  801e4f:	89 e5                	mov    %esp,%ebp
  801e51:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801e54:	8b 45 08             	mov    0x8(%ebp),%eax
  801e57:	e8 75 ff ff ff       	call   801dd1 <fd2sockid>
  801e5c:	85 c0                	test   %eax,%eax
  801e5e:	78 0f                	js     801e6f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  801e60:	8b 55 0c             	mov    0xc(%ebp),%edx
  801e63:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e67:	89 04 24             	mov    %eax,(%esp)
  801e6a:	e8 1c 01 00 00       	call   801f8b <nsipc_shutdown>
}
  801e6f:	c9                   	leave  
  801e70:	c3                   	ret    

00801e71 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  801e71:	55                   	push   %ebp
  801e72:	89 e5                	mov    %esp,%ebp
  801e74:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801e77:	8b 45 08             	mov    0x8(%ebp),%eax
  801e7a:	e8 52 ff ff ff       	call   801dd1 <fd2sockid>
  801e7f:	85 c0                	test   %eax,%eax
  801e81:	78 16                	js     801e99 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  801e83:	8b 55 10             	mov    0x10(%ebp),%edx
  801e86:	89 54 24 08          	mov    %edx,0x8(%esp)
  801e8a:	8b 55 0c             	mov    0xc(%ebp),%edx
  801e8d:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e91:	89 04 24             	mov    %eax,(%esp)
  801e94:	e8 46 02 00 00       	call   8020df <nsipc_bind>
}
  801e99:	c9                   	leave  
  801e9a:	c3                   	ret    

00801e9b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  801e9b:	55                   	push   %ebp
  801e9c:	89 e5                	mov    %esp,%ebp
  801e9e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801ea1:	8b 45 08             	mov    0x8(%ebp),%eax
  801ea4:	e8 28 ff ff ff       	call   801dd1 <fd2sockid>
  801ea9:	85 c0                	test   %eax,%eax
  801eab:	78 1f                	js     801ecc <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  801ead:	8b 55 10             	mov    0x10(%ebp),%edx
  801eb0:	89 54 24 08          	mov    %edx,0x8(%esp)
  801eb4:	8b 55 0c             	mov    0xc(%ebp),%edx
  801eb7:	89 54 24 04          	mov    %edx,0x4(%esp)
  801ebb:	89 04 24             	mov    %eax,(%esp)
  801ebe:	e8 5b 02 00 00       	call   80211e <nsipc_accept>
  801ec3:	85 c0                	test   %eax,%eax
  801ec5:	78 05                	js     801ecc <accept+0x31>
		return r;
	return alloc_sockfd(r);
  801ec7:	e8 62 fe ff ff       	call   801d2e <alloc_sockfd>
}
  801ecc:	c9                   	leave  
  801ecd:	8d 76 00             	lea    0x0(%esi),%esi
  801ed0:	c3                   	ret    
	...

00801ee0 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  801ee0:	55                   	push   %ebp
  801ee1:	89 e5                	mov    %esp,%ebp
  801ee3:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  801ee6:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  801eec:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  801ef3:	00 
  801ef4:	c7 44 24 08 00 50 80 	movl   $0x805000,0x8(%esp)
  801efb:	00 
  801efc:	89 44 24 04          	mov    %eax,0x4(%esp)
  801f00:	89 14 24             	mov    %edx,(%esp)
  801f03:	e8 18 08 00 00       	call   802720 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  801f08:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801f0f:	00 
  801f10:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801f17:	00 
  801f18:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801f1b:	89 04 24             	mov    %eax,(%esp)
  801f1e:	e8 6f 08 00 00       	call   802792 <ipc_recv>
    return r;
}
  801f23:	c9                   	leave  
  801f24:	c3                   	ret    

00801f25 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  801f25:	55                   	push   %ebp
  801f26:	89 e5                	mov    %esp,%ebp
  801f28:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  801f2b:	8b 45 08             	mov    0x8(%ebp),%eax
  801f2e:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.socket.req_type = type;
  801f33:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f36:	a3 04 50 80 00       	mov    %eax,0x805004
	nsipcbuf.socket.req_protocol = protocol;
  801f3b:	8b 45 10             	mov    0x10(%ebp),%eax
  801f3e:	a3 08 50 80 00       	mov    %eax,0x805008
	return nsipc(NSREQ_SOCKET);
  801f43:	b8 09 00 00 00       	mov    $0x9,%eax
  801f48:	e8 93 ff ff ff       	call   801ee0 <nsipc>
}
  801f4d:	c9                   	leave  
  801f4e:	c3                   	ret    

00801f4f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  801f4f:	55                   	push   %ebp
  801f50:	89 e5                	mov    %esp,%ebp
  801f52:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  801f55:	8b 45 08             	mov    0x8(%ebp),%eax
  801f58:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.listen.req_backlog = backlog;
  801f5d:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f60:	a3 04 50 80 00       	mov    %eax,0x805004
	return nsipc(NSREQ_LISTEN);
  801f65:	b8 06 00 00 00       	mov    $0x6,%eax
  801f6a:	e8 71 ff ff ff       	call   801ee0 <nsipc>
}
  801f6f:	c9                   	leave  
  801f70:	c3                   	ret    

00801f71 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  801f71:	55                   	push   %ebp
  801f72:	89 e5                	mov    %esp,%ebp
  801f74:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  801f77:	8b 45 08             	mov    0x8(%ebp),%eax
  801f7a:	a3 00 50 80 00       	mov    %eax,0x805000
	return nsipc(NSREQ_CLOSE);
  801f7f:	b8 04 00 00 00       	mov    $0x4,%eax
  801f84:	e8 57 ff ff ff       	call   801ee0 <nsipc>
}
  801f89:	c9                   	leave  
  801f8a:	c3                   	ret    

00801f8b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  801f8b:	55                   	push   %ebp
  801f8c:	89 e5                	mov    %esp,%ebp
  801f8e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  801f91:	8b 45 08             	mov    0x8(%ebp),%eax
  801f94:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.shutdown.req_how = how;
  801f99:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f9c:	a3 04 50 80 00       	mov    %eax,0x805004
	return nsipc(NSREQ_SHUTDOWN);
  801fa1:	b8 03 00 00 00       	mov    $0x3,%eax
  801fa6:	e8 35 ff ff ff       	call   801ee0 <nsipc>
}
  801fab:	c9                   	leave  
  801fac:	c3                   	ret    

00801fad <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  801fad:	55                   	push   %ebp
  801fae:	89 e5                	mov    %esp,%ebp
  801fb0:	53                   	push   %ebx
  801fb1:	83 ec 14             	sub    $0x14,%esp
  801fb4:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  801fb7:	8b 45 08             	mov    0x8(%ebp),%eax
  801fba:	a3 00 50 80 00       	mov    %eax,0x805000
	assert(size < 1600);
  801fbf:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  801fc5:	7e 24                	jle    801feb <nsipc_send+0x3e>
  801fc7:	c7 44 24 0c 14 2f 80 	movl   $0x802f14,0xc(%esp)
  801fce:	00 
  801fcf:	c7 44 24 08 20 2f 80 	movl   $0x802f20,0x8(%esp)
  801fd6:	00 
  801fd7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  801fde:	00 
  801fdf:	c7 04 24 35 2f 80 00 	movl   $0x802f35,(%esp)
  801fe6:	e8 51 e2 ff ff       	call   80023c <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  801feb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801fef:	8b 45 0c             	mov    0xc(%ebp),%eax
  801ff2:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ff6:	c7 04 24 0c 50 80 00 	movl   $0x80500c,(%esp)
  801ffd:	e8 83 eb ff ff       	call   800b85 <memmove>
	nsipcbuf.send.req_size = size;
  802002:	89 1d 04 50 80 00    	mov    %ebx,0x805004
	nsipcbuf.send.req_flags = flags;
  802008:	8b 45 14             	mov    0x14(%ebp),%eax
  80200b:	a3 08 50 80 00       	mov    %eax,0x805008
	return nsipc(NSREQ_SEND);
  802010:	b8 08 00 00 00       	mov    $0x8,%eax
  802015:	e8 c6 fe ff ff       	call   801ee0 <nsipc>
}
  80201a:	83 c4 14             	add    $0x14,%esp
  80201d:	5b                   	pop    %ebx
  80201e:	5d                   	pop    %ebp
  80201f:	c3                   	ret    

00802020 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  802020:	55                   	push   %ebp
  802021:	89 e5                	mov    %esp,%ebp
  802023:	56                   	push   %esi
  802024:	53                   	push   %ebx
  802025:	83 ec 10             	sub    $0x10,%esp
  802028:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  80202b:	8b 45 08             	mov    0x8(%ebp),%eax
  80202e:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.recv.req_len = len;
  802033:	89 35 04 50 80 00    	mov    %esi,0x805004
	nsipcbuf.recv.req_flags = flags;
  802039:	8b 45 14             	mov    0x14(%ebp),%eax
  80203c:	a3 08 50 80 00       	mov    %eax,0x805008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  802041:	b8 07 00 00 00       	mov    $0x7,%eax
  802046:	e8 95 fe ff ff       	call   801ee0 <nsipc>
  80204b:	89 c3                	mov    %eax,%ebx
  80204d:	85 c0                	test   %eax,%eax
  80204f:	78 46                	js     802097 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  802051:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  802056:	7f 04                	jg     80205c <nsipc_recv+0x3c>
  802058:	39 c6                	cmp    %eax,%esi
  80205a:	7d 24                	jge    802080 <nsipc_recv+0x60>
  80205c:	c7 44 24 0c 41 2f 80 	movl   $0x802f41,0xc(%esp)
  802063:	00 
  802064:	c7 44 24 08 20 2f 80 	movl   $0x802f20,0x8(%esp)
  80206b:	00 
  80206c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802073:	00 
  802074:	c7 04 24 35 2f 80 00 	movl   $0x802f35,(%esp)
  80207b:	e8 bc e1 ff ff       	call   80023c <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  802080:	89 44 24 08          	mov    %eax,0x8(%esp)
  802084:	c7 44 24 04 00 50 80 	movl   $0x805000,0x4(%esp)
  80208b:	00 
  80208c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80208f:	89 04 24             	mov    %eax,(%esp)
  802092:	e8 ee ea ff ff       	call   800b85 <memmove>
	}

	return r;
}
  802097:	89 d8                	mov    %ebx,%eax
  802099:	83 c4 10             	add    $0x10,%esp
  80209c:	5b                   	pop    %ebx
  80209d:	5e                   	pop    %esi
  80209e:	5d                   	pop    %ebp
  80209f:	c3                   	ret    

008020a0 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  8020a0:	55                   	push   %ebp
  8020a1:	89 e5                	mov    %esp,%ebp
  8020a3:	53                   	push   %ebx
  8020a4:	83 ec 14             	sub    $0x14,%esp
  8020a7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  8020aa:	8b 45 08             	mov    0x8(%ebp),%eax
  8020ad:	a3 00 50 80 00       	mov    %eax,0x805000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  8020b2:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8020b6:	8b 45 0c             	mov    0xc(%ebp),%eax
  8020b9:	89 44 24 04          	mov    %eax,0x4(%esp)
  8020bd:	c7 04 24 04 50 80 00 	movl   $0x805004,(%esp)
  8020c4:	e8 bc ea ff ff       	call   800b85 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  8020c9:	89 1d 14 50 80 00    	mov    %ebx,0x805014
	return nsipc(NSREQ_CONNECT);
  8020cf:	b8 05 00 00 00       	mov    $0x5,%eax
  8020d4:	e8 07 fe ff ff       	call   801ee0 <nsipc>
}
  8020d9:	83 c4 14             	add    $0x14,%esp
  8020dc:	5b                   	pop    %ebx
  8020dd:	5d                   	pop    %ebp
  8020de:	c3                   	ret    

008020df <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8020df:	55                   	push   %ebp
  8020e0:	89 e5                	mov    %esp,%ebp
  8020e2:	53                   	push   %ebx
  8020e3:	83 ec 14             	sub    $0x14,%esp
  8020e6:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  8020e9:	8b 45 08             	mov    0x8(%ebp),%eax
  8020ec:	a3 00 50 80 00       	mov    %eax,0x805000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  8020f1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8020f5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8020f8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8020fc:	c7 04 24 04 50 80 00 	movl   $0x805004,(%esp)
  802103:	e8 7d ea ff ff       	call   800b85 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  802108:	89 1d 14 50 80 00    	mov    %ebx,0x805014
	return nsipc(NSREQ_BIND);
  80210e:	b8 02 00 00 00       	mov    $0x2,%eax
  802113:	e8 c8 fd ff ff       	call   801ee0 <nsipc>
}
  802118:	83 c4 14             	add    $0x14,%esp
  80211b:	5b                   	pop    %ebx
  80211c:	5d                   	pop    %ebp
  80211d:	c3                   	ret    

0080211e <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80211e:	55                   	push   %ebp
  80211f:	89 e5                	mov    %esp,%ebp
  802121:	83 ec 18             	sub    $0x18,%esp
  802124:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802127:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  80212a:	8b 45 08             	mov    0x8(%ebp),%eax
  80212d:	a3 00 50 80 00       	mov    %eax,0x805000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  802132:	b8 01 00 00 00       	mov    $0x1,%eax
  802137:	e8 a4 fd ff ff       	call   801ee0 <nsipc>
  80213c:	89 c3                	mov    %eax,%ebx
  80213e:	85 c0                	test   %eax,%eax
  802140:	78 25                	js     802167 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  802142:	be 10 50 80 00       	mov    $0x805010,%esi
  802147:	8b 06                	mov    (%esi),%eax
  802149:	89 44 24 08          	mov    %eax,0x8(%esp)
  80214d:	c7 44 24 04 00 50 80 	movl   $0x805000,0x4(%esp)
  802154:	00 
  802155:	8b 45 0c             	mov    0xc(%ebp),%eax
  802158:	89 04 24             	mov    %eax,(%esp)
  80215b:	e8 25 ea ff ff       	call   800b85 <memmove>
		*addrlen = ret->ret_addrlen;
  802160:	8b 16                	mov    (%esi),%edx
  802162:	8b 45 10             	mov    0x10(%ebp),%eax
  802165:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802167:	89 d8                	mov    %ebx,%eax
  802169:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80216c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80216f:	89 ec                	mov    %ebp,%esp
  802171:	5d                   	pop    %ebp
  802172:	c3                   	ret    
	...

00802180 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  802180:	55                   	push   %ebp
  802181:	89 e5                	mov    %esp,%ebp
  802183:	83 ec 18             	sub    $0x18,%esp
  802186:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802189:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80218c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  80218f:	8b 45 08             	mov    0x8(%ebp),%eax
  802192:	89 04 24             	mov    %eax,(%esp)
  802195:	e8 c6 f0 ff ff       	call   801260 <fd2data>
  80219a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  80219c:	c7 44 24 04 56 2f 80 	movl   $0x802f56,0x4(%esp)
  8021a3:	00 
  8021a4:	89 34 24             	mov    %esi,(%esp)
  8021a7:	e8 1e e8 ff ff       	call   8009ca <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  8021ac:	8b 43 04             	mov    0x4(%ebx),%eax
  8021af:	2b 03                	sub    (%ebx),%eax
  8021b1:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  8021b7:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  8021be:	00 00 00 
	stat->st_dev = &devpipe;
  8021c1:	c7 86 88 00 00 00 40 	movl   $0x806040,0x88(%esi)
  8021c8:	60 80 00 
	return 0;
}
  8021cb:	b8 00 00 00 00       	mov    $0x0,%eax
  8021d0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8021d3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8021d6:	89 ec                	mov    %ebp,%esp
  8021d8:	5d                   	pop    %ebp
  8021d9:	c3                   	ret    

008021da <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  8021da:	55                   	push   %ebp
  8021db:	89 e5                	mov    %esp,%ebp
  8021dd:	53                   	push   %ebx
  8021de:	83 ec 14             	sub    $0x14,%esp
  8021e1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  8021e4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8021e8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8021ef:	e8 76 ee ff ff       	call   80106a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  8021f4:	89 1c 24             	mov    %ebx,(%esp)
  8021f7:	e8 64 f0 ff ff       	call   801260 <fd2data>
  8021fc:	89 44 24 04          	mov    %eax,0x4(%esp)
  802200:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802207:	e8 5e ee ff ff       	call   80106a <sys_page_unmap>
}
  80220c:	83 c4 14             	add    $0x14,%esp
  80220f:	5b                   	pop    %ebx
  802210:	5d                   	pop    %ebp
  802211:	c3                   	ret    

00802212 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  802212:	55                   	push   %ebp
  802213:	89 e5                	mov    %esp,%ebp
  802215:	57                   	push   %edi
  802216:	56                   	push   %esi
  802217:	53                   	push   %ebx
  802218:	83 ec 2c             	sub    $0x2c,%esp
  80221b:	89 c7                	mov    %eax,%edi
  80221d:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  802220:	a1 7c 60 80 00       	mov    0x80607c,%eax
  802225:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  802228:	89 3c 24             	mov    %edi,(%esp)
  80222b:	e8 b4 05 00 00       	call   8027e4 <pageref>
  802230:	89 c6                	mov    %eax,%esi
  802232:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802235:	89 04 24             	mov    %eax,(%esp)
  802238:	e8 a7 05 00 00       	call   8027e4 <pageref>
  80223d:	39 c6                	cmp    %eax,%esi
  80223f:	0f 94 c0             	sete   %al
  802242:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  802245:	8b 15 7c 60 80 00    	mov    0x80607c,%edx
  80224b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  80224e:	39 cb                	cmp    %ecx,%ebx
  802250:	75 08                	jne    80225a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  802252:	83 c4 2c             	add    $0x2c,%esp
  802255:	5b                   	pop    %ebx
  802256:	5e                   	pop    %esi
  802257:	5f                   	pop    %edi
  802258:	5d                   	pop    %ebp
  802259:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  80225a:	83 f8 01             	cmp    $0x1,%eax
  80225d:	75 c1                	jne    802220 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  80225f:	8b 52 58             	mov    0x58(%edx),%edx
  802262:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802266:	89 54 24 08          	mov    %edx,0x8(%esp)
  80226a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80226e:	c7 04 24 5d 2f 80 00 	movl   $0x802f5d,(%esp)
  802275:	e8 87 e0 ff ff       	call   800301 <cprintf>
  80227a:	eb a4                	jmp    802220 <_pipeisclosed+0xe>

0080227c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80227c:	55                   	push   %ebp
  80227d:	89 e5                	mov    %esp,%ebp
  80227f:	57                   	push   %edi
  802280:	56                   	push   %esi
  802281:	53                   	push   %ebx
  802282:	83 ec 1c             	sub    $0x1c,%esp
  802285:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  802288:	89 34 24             	mov    %esi,(%esp)
  80228b:	e8 d0 ef ff ff       	call   801260 <fd2data>
  802290:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802292:	bf 00 00 00 00       	mov    $0x0,%edi
  802297:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80229b:	75 54                	jne    8022f1 <devpipe_write+0x75>
  80229d:	eb 60                	jmp    8022ff <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  80229f:	89 da                	mov    %ebx,%edx
  8022a1:	89 f0                	mov    %esi,%eax
  8022a3:	e8 6a ff ff ff       	call   802212 <_pipeisclosed>
  8022a8:	85 c0                	test   %eax,%eax
  8022aa:	74 07                	je     8022b3 <devpipe_write+0x37>
  8022ac:	b8 00 00 00 00       	mov    $0x0,%eax
  8022b1:	eb 53                	jmp    802306 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  8022b3:	90                   	nop
  8022b4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8022b8:	e8 c8 ee ff ff       	call   801185 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8022bd:	8b 43 04             	mov    0x4(%ebx),%eax
  8022c0:	8b 13                	mov    (%ebx),%edx
  8022c2:	83 c2 20             	add    $0x20,%edx
  8022c5:	39 d0                	cmp    %edx,%eax
  8022c7:	73 d6                	jae    80229f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  8022c9:	89 c2                	mov    %eax,%edx
  8022cb:	c1 fa 1f             	sar    $0x1f,%edx
  8022ce:	c1 ea 1b             	shr    $0x1b,%edx
  8022d1:	01 d0                	add    %edx,%eax
  8022d3:	83 e0 1f             	and    $0x1f,%eax
  8022d6:	29 d0                	sub    %edx,%eax
  8022d8:	89 c2                	mov    %eax,%edx
  8022da:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8022dd:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  8022e1:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  8022e5:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8022e9:	83 c7 01             	add    $0x1,%edi
  8022ec:	39 7d 10             	cmp    %edi,0x10(%ebp)
  8022ef:	76 13                	jbe    802304 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8022f1:	8b 43 04             	mov    0x4(%ebx),%eax
  8022f4:	8b 13                	mov    (%ebx),%edx
  8022f6:	83 c2 20             	add    $0x20,%edx
  8022f9:	39 d0                	cmp    %edx,%eax
  8022fb:	73 a2                	jae    80229f <devpipe_write+0x23>
  8022fd:	eb ca                	jmp    8022c9 <devpipe_write+0x4d>
  8022ff:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  802304:	89 f8                	mov    %edi,%eax
}
  802306:	83 c4 1c             	add    $0x1c,%esp
  802309:	5b                   	pop    %ebx
  80230a:	5e                   	pop    %esi
  80230b:	5f                   	pop    %edi
  80230c:	5d                   	pop    %ebp
  80230d:	c3                   	ret    

0080230e <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  80230e:	55                   	push   %ebp
  80230f:	89 e5                	mov    %esp,%ebp
  802311:	83 ec 28             	sub    $0x28,%esp
  802314:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802317:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80231a:	89 7d fc             	mov    %edi,-0x4(%ebp)
  80231d:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  802320:	89 3c 24             	mov    %edi,(%esp)
  802323:	e8 38 ef ff ff       	call   801260 <fd2data>
  802328:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  80232a:	be 00 00 00 00       	mov    $0x0,%esi
  80232f:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802333:	75 4c                	jne    802381 <devpipe_read+0x73>
  802335:	eb 5b                	jmp    802392 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  802337:	89 f0                	mov    %esi,%eax
  802339:	eb 5e                	jmp    802399 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  80233b:	89 da                	mov    %ebx,%edx
  80233d:	89 f8                	mov    %edi,%eax
  80233f:	90                   	nop
  802340:	e8 cd fe ff ff       	call   802212 <_pipeisclosed>
  802345:	85 c0                	test   %eax,%eax
  802347:	74 07                	je     802350 <devpipe_read+0x42>
  802349:	b8 00 00 00 00       	mov    $0x0,%eax
  80234e:	eb 49                	jmp    802399 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  802350:	e8 30 ee ff ff       	call   801185 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  802355:	8b 03                	mov    (%ebx),%eax
  802357:	3b 43 04             	cmp    0x4(%ebx),%eax
  80235a:	74 df                	je     80233b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80235c:	89 c2                	mov    %eax,%edx
  80235e:	c1 fa 1f             	sar    $0x1f,%edx
  802361:	c1 ea 1b             	shr    $0x1b,%edx
  802364:	01 d0                	add    %edx,%eax
  802366:	83 e0 1f             	and    $0x1f,%eax
  802369:	29 d0                	sub    %edx,%eax
  80236b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802370:	8b 55 0c             	mov    0xc(%ebp),%edx
  802373:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  802376:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802379:	83 c6 01             	add    $0x1,%esi
  80237c:	39 75 10             	cmp    %esi,0x10(%ebp)
  80237f:	76 16                	jbe    802397 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  802381:	8b 03                	mov    (%ebx),%eax
  802383:	3b 43 04             	cmp    0x4(%ebx),%eax
  802386:	75 d4                	jne    80235c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  802388:	85 f6                	test   %esi,%esi
  80238a:	75 ab                	jne    802337 <devpipe_read+0x29>
  80238c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802390:	eb a9                	jmp    80233b <devpipe_read+0x2d>
  802392:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  802397:	89 f0                	mov    %esi,%eax
}
  802399:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80239c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80239f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8023a2:	89 ec                	mov    %ebp,%esp
  8023a4:	5d                   	pop    %ebp
  8023a5:	c3                   	ret    

008023a6 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  8023a6:	55                   	push   %ebp
  8023a7:	89 e5                	mov    %esp,%ebp
  8023a9:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8023ac:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8023af:	89 44 24 04          	mov    %eax,0x4(%esp)
  8023b3:	8b 45 08             	mov    0x8(%ebp),%eax
  8023b6:	89 04 24             	mov    %eax,(%esp)
  8023b9:	e8 2f ef ff ff       	call   8012ed <fd_lookup>
  8023be:	85 c0                	test   %eax,%eax
  8023c0:	78 15                	js     8023d7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  8023c2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8023c5:	89 04 24             	mov    %eax,(%esp)
  8023c8:	e8 93 ee ff ff       	call   801260 <fd2data>
	return _pipeisclosed(fd, p);
  8023cd:	89 c2                	mov    %eax,%edx
  8023cf:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8023d2:	e8 3b fe ff ff       	call   802212 <_pipeisclosed>
}
  8023d7:	c9                   	leave  
  8023d8:	c3                   	ret    

008023d9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  8023d9:	55                   	push   %ebp
  8023da:	89 e5                	mov    %esp,%ebp
  8023dc:	83 ec 48             	sub    $0x48,%esp
  8023df:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8023e2:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8023e5:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8023e8:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8023eb:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8023ee:	89 04 24             	mov    %eax,(%esp)
  8023f1:	e8 85 ee ff ff       	call   80127b <fd_alloc>
  8023f6:	89 c3                	mov    %eax,%ebx
  8023f8:	85 c0                	test   %eax,%eax
  8023fa:	0f 88 42 01 00 00    	js     802542 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802400:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802407:	00 
  802408:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80240b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80240f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802416:	e8 0b ed ff ff       	call   801126 <sys_page_alloc>
  80241b:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  80241d:	85 c0                	test   %eax,%eax
  80241f:	0f 88 1d 01 00 00    	js     802542 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802425:	8d 45 e0             	lea    -0x20(%ebp),%eax
  802428:	89 04 24             	mov    %eax,(%esp)
  80242b:	e8 4b ee ff ff       	call   80127b <fd_alloc>
  802430:	89 c3                	mov    %eax,%ebx
  802432:	85 c0                	test   %eax,%eax
  802434:	0f 88 f5 00 00 00    	js     80252f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80243a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802441:	00 
  802442:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802445:	89 44 24 04          	mov    %eax,0x4(%esp)
  802449:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802450:	e8 d1 ec ff ff       	call   801126 <sys_page_alloc>
  802455:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802457:	85 c0                	test   %eax,%eax
  802459:	0f 88 d0 00 00 00    	js     80252f <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  80245f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802462:	89 04 24             	mov    %eax,(%esp)
  802465:	e8 f6 ed ff ff       	call   801260 <fd2data>
  80246a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80246c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802473:	00 
  802474:	89 44 24 04          	mov    %eax,0x4(%esp)
  802478:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80247f:	e8 a2 ec ff ff       	call   801126 <sys_page_alloc>
  802484:	89 c3                	mov    %eax,%ebx
  802486:	85 c0                	test   %eax,%eax
  802488:	0f 88 8e 00 00 00    	js     80251c <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80248e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802491:	89 04 24             	mov    %eax,(%esp)
  802494:	e8 c7 ed ff ff       	call   801260 <fd2data>
  802499:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  8024a0:	00 
  8024a1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8024a5:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8024ac:	00 
  8024ad:	89 74 24 04          	mov    %esi,0x4(%esp)
  8024b1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8024b8:	e8 0b ec ff ff       	call   8010c8 <sys_page_map>
  8024bd:	89 c3                	mov    %eax,%ebx
  8024bf:	85 c0                	test   %eax,%eax
  8024c1:	78 49                	js     80250c <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  8024c3:	b8 40 60 80 00       	mov    $0x806040,%eax
  8024c8:	8b 08                	mov    (%eax),%ecx
  8024ca:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8024cd:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  8024cf:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8024d2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  8024d9:	8b 10                	mov    (%eax),%edx
  8024db:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8024de:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  8024e0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8024e3:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  8024ea:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8024ed:	89 04 24             	mov    %eax,(%esp)
  8024f0:	e8 5b ed ff ff       	call   801250 <fd2num>
  8024f5:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  8024f7:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8024fa:	89 04 24             	mov    %eax,(%esp)
  8024fd:	e8 4e ed ff ff       	call   801250 <fd2num>
  802502:	89 47 04             	mov    %eax,0x4(%edi)
  802505:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  80250a:	eb 36                	jmp    802542 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  80250c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802510:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802517:	e8 4e eb ff ff       	call   80106a <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  80251c:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80251f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802523:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80252a:	e8 3b eb ff ff       	call   80106a <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  80252f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802532:	89 44 24 04          	mov    %eax,0x4(%esp)
  802536:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80253d:	e8 28 eb ff ff       	call   80106a <sys_page_unmap>
    err:
	return r;
}
  802542:	89 d8                	mov    %ebx,%eax
  802544:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802547:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80254a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80254d:	89 ec                	mov    %ebp,%esp
  80254f:	5d                   	pop    %ebp
  802550:	c3                   	ret    
	...

00802560 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  802560:	55                   	push   %ebp
  802561:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  802563:	b8 00 00 00 00       	mov    $0x0,%eax
  802568:	5d                   	pop    %ebp
  802569:	c3                   	ret    

0080256a <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  80256a:	55                   	push   %ebp
  80256b:	89 e5                	mov    %esp,%ebp
  80256d:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  802570:	c7 44 24 04 75 2f 80 	movl   $0x802f75,0x4(%esp)
  802577:	00 
  802578:	8b 45 0c             	mov    0xc(%ebp),%eax
  80257b:	89 04 24             	mov    %eax,(%esp)
  80257e:	e8 47 e4 ff ff       	call   8009ca <strcpy>
	return 0;
}
  802583:	b8 00 00 00 00       	mov    $0x0,%eax
  802588:	c9                   	leave  
  802589:	c3                   	ret    

0080258a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80258a:	55                   	push   %ebp
  80258b:	89 e5                	mov    %esp,%ebp
  80258d:	57                   	push   %edi
  80258e:	56                   	push   %esi
  80258f:	53                   	push   %ebx
  802590:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802596:	b8 00 00 00 00       	mov    $0x0,%eax
  80259b:	be 00 00 00 00       	mov    $0x0,%esi
  8025a0:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8025a4:	74 41                	je     8025e7 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  8025a6:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  8025ac:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8025af:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  8025b1:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  8025b7:	ba 7f 00 00 00       	mov    $0x7f,%edx
  8025bc:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  8025bf:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8025c3:	03 45 0c             	add    0xc(%ebp),%eax
  8025c6:	89 44 24 04          	mov    %eax,0x4(%esp)
  8025ca:	89 3c 24             	mov    %edi,(%esp)
  8025cd:	e8 b3 e5 ff ff       	call   800b85 <memmove>
		sys_cputs(buf, m);
  8025d2:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8025d6:	89 3c 24             	mov    %edi,(%esp)
  8025d9:	e8 e2 e7 ff ff       	call   800dc0 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  8025de:	01 de                	add    %ebx,%esi
  8025e0:	89 f0                	mov    %esi,%eax
  8025e2:	3b 75 10             	cmp    0x10(%ebp),%esi
  8025e5:	72 c5                	jb     8025ac <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  8025e7:	89 f0                	mov    %esi,%eax
  8025e9:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  8025ef:	5b                   	pop    %ebx
  8025f0:	5e                   	pop    %esi
  8025f1:	5f                   	pop    %edi
  8025f2:	5d                   	pop    %ebp
  8025f3:	c3                   	ret    

008025f4 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  8025f4:	55                   	push   %ebp
  8025f5:	89 e5                	mov    %esp,%ebp
  8025f7:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  8025fa:	8b 45 08             	mov    0x8(%ebp),%eax
  8025fd:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  802600:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  802607:	00 
  802608:	8d 45 f7             	lea    -0x9(%ebp),%eax
  80260b:	89 04 24             	mov    %eax,(%esp)
  80260e:	e8 ad e7 ff ff       	call   800dc0 <sys_cputs>
}
  802613:	c9                   	leave  
  802614:	c3                   	ret    

00802615 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  802615:	55                   	push   %ebp
  802616:	89 e5                	mov    %esp,%ebp
  802618:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  80261b:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80261f:	75 07                	jne    802628 <devcons_read+0x13>
  802621:	eb 2d                	jmp    802650 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  802623:	e8 5d eb ff ff       	call   801185 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  802628:	90                   	nop
  802629:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802630:	e8 57 e7 ff ff       	call   800d8c <sys_cgetc>
  802635:	85 c0                	test   %eax,%eax
  802637:	74 ea                	je     802623 <devcons_read+0xe>
  802639:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  80263b:	85 c0                	test   %eax,%eax
  80263d:	78 16                	js     802655 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  80263f:	83 f8 04             	cmp    $0x4,%eax
  802642:	74 0c                	je     802650 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  802644:	8b 45 0c             	mov    0xc(%ebp),%eax
  802647:	88 10                	mov    %dl,(%eax)
  802649:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  80264e:	eb 05                	jmp    802655 <devcons_read+0x40>
  802650:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802655:	c9                   	leave  
  802656:	c3                   	ret    

00802657 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  802657:	55                   	push   %ebp
  802658:	89 e5                	mov    %esp,%ebp
  80265a:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  80265d:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802660:	89 04 24             	mov    %eax,(%esp)
  802663:	e8 13 ec ff ff       	call   80127b <fd_alloc>
  802668:	85 c0                	test   %eax,%eax
  80266a:	78 3f                	js     8026ab <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  80266c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802673:	00 
  802674:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802677:	89 44 24 04          	mov    %eax,0x4(%esp)
  80267b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802682:	e8 9f ea ff ff       	call   801126 <sys_page_alloc>
  802687:	85 c0                	test   %eax,%eax
  802689:	78 20                	js     8026ab <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  80268b:	8b 15 5c 60 80 00    	mov    0x80605c,%edx
  802691:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802694:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802696:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802699:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  8026a0:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8026a3:	89 04 24             	mov    %eax,(%esp)
  8026a6:	e8 a5 eb ff ff       	call   801250 <fd2num>
}
  8026ab:	c9                   	leave  
  8026ac:	c3                   	ret    

008026ad <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  8026ad:	55                   	push   %ebp
  8026ae:	89 e5                	mov    %esp,%ebp
  8026b0:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8026b3:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8026b6:	89 44 24 04          	mov    %eax,0x4(%esp)
  8026ba:	8b 45 08             	mov    0x8(%ebp),%eax
  8026bd:	89 04 24             	mov    %eax,(%esp)
  8026c0:	e8 28 ec ff ff       	call   8012ed <fd_lookup>
  8026c5:	85 c0                	test   %eax,%eax
  8026c7:	78 11                	js     8026da <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  8026c9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8026cc:	8b 00                	mov    (%eax),%eax
  8026ce:	3b 05 5c 60 80 00    	cmp    0x80605c,%eax
  8026d4:	0f 94 c0             	sete   %al
  8026d7:	0f b6 c0             	movzbl %al,%eax
}
  8026da:	c9                   	leave  
  8026db:	c3                   	ret    

008026dc <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  8026dc:	55                   	push   %ebp
  8026dd:	89 e5                	mov    %esp,%ebp
  8026df:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  8026e2:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  8026e9:	00 
  8026ea:	8d 45 f7             	lea    -0x9(%ebp),%eax
  8026ed:	89 44 24 04          	mov    %eax,0x4(%esp)
  8026f1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026f8:	e8 56 ee ff ff       	call   801553 <read>
	if (r < 0)
  8026fd:	85 c0                	test   %eax,%eax
  8026ff:	78 0f                	js     802710 <getchar+0x34>
		return r;
	if (r < 1)
  802701:	85 c0                	test   %eax,%eax
  802703:	7f 07                	jg     80270c <getchar+0x30>
  802705:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  80270a:	eb 04                	jmp    802710 <getchar+0x34>
		return -E_EOF;
	return c;
  80270c:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  802710:	c9                   	leave  
  802711:	c3                   	ret    
	...

00802720 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  802720:	55                   	push   %ebp
  802721:	89 e5                	mov    %esp,%ebp
  802723:	57                   	push   %edi
  802724:	56                   	push   %esi
  802725:	53                   	push   %ebx
  802726:	83 ec 2c             	sub    $0x2c,%esp
  802729:	8b 75 08             	mov    0x8(%ebp),%esi
  80272c:	8b 7d 0c             	mov    0xc(%ebp),%edi
  80272f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  802732:	85 db                	test   %ebx,%ebx
  802734:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  802739:	0f 45 c3             	cmovne %ebx,%eax
  80273c:	8b 55 14             	mov    0x14(%ebp),%edx
  80273f:	89 54 24 0c          	mov    %edx,0xc(%esp)
  802743:	89 44 24 08          	mov    %eax,0x8(%esp)
  802747:	89 7c 24 04          	mov    %edi,0x4(%esp)
  80274b:	89 34 24             	mov    %esi,(%esp)
  80274e:	e8 9d e7 ff ff       	call   800ef0 <sys_ipc_try_send>
  802753:	83 f8 f9             	cmp    $0xfffffff9,%eax
  802756:	75 0a                	jne    802762 <ipc_send+0x42>
      sys_yield();
  802758:	e8 28 ea ff ff       	call   801185 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  80275d:	8d 76 00             	lea    0x0(%esi),%esi
  802760:	eb d0                	jmp    802732 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  802762:	85 c0                	test   %eax,%eax
  802764:	79 24                	jns    80278a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  802766:	89 44 24 10          	mov    %eax,0x10(%esp)
  80276a:	89 74 24 0c          	mov    %esi,0xc(%esp)
  80276e:	c7 44 24 08 84 2f 80 	movl   $0x802f84,0x8(%esp)
  802775:	00 
  802776:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  80277d:	00 
  80277e:	c7 04 24 a8 2f 80 00 	movl   $0x802fa8,(%esp)
  802785:	e8 b2 da ff ff       	call   80023c <_panic>
    else
      return;
  }
}
  80278a:	83 c4 2c             	add    $0x2c,%esp
  80278d:	5b                   	pop    %ebx
  80278e:	5e                   	pop    %esi
  80278f:	5f                   	pop    %edi
  802790:	5d                   	pop    %ebp
  802791:	c3                   	ret    

00802792 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  802792:	55                   	push   %ebp
  802793:	89 e5                	mov    %esp,%ebp
  802795:	56                   	push   %esi
  802796:	53                   	push   %ebx
  802797:	83 ec 10             	sub    $0x10,%esp
  80279a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80279d:	8b 45 0c             	mov    0xc(%ebp),%eax
  8027a0:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  8027a3:	85 c0                	test   %eax,%eax
  8027a5:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  8027aa:	0f 44 c2             	cmove  %edx,%eax
  8027ad:	89 04 24             	mov    %eax,(%esp)
  8027b0:	e8 de e6 ff ff       	call   800e93 <sys_ipc_recv>
  8027b5:	85 c0                	test   %eax,%eax
  8027b7:	78 24                	js     8027dd <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  8027b9:	85 db                	test   %ebx,%ebx
  8027bb:	74 0a                	je     8027c7 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  8027bd:	a1 7c 60 80 00       	mov    0x80607c,%eax
  8027c2:	8b 40 74             	mov    0x74(%eax),%eax
  8027c5:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  8027c7:	85 f6                	test   %esi,%esi
  8027c9:	74 0a                	je     8027d5 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  8027cb:	a1 7c 60 80 00       	mov    0x80607c,%eax
  8027d0:	8b 40 78             	mov    0x78(%eax),%eax
  8027d3:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  8027d5:	a1 7c 60 80 00       	mov    0x80607c,%eax
  8027da:	8b 40 70             	mov    0x70(%eax),%eax
}
  8027dd:	83 c4 10             	add    $0x10,%esp
  8027e0:	5b                   	pop    %ebx
  8027e1:	5e                   	pop    %esi
  8027e2:	5d                   	pop    %ebp
  8027e3:	c3                   	ret    

008027e4 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  8027e4:	55                   	push   %ebp
  8027e5:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  8027e7:	8b 45 08             	mov    0x8(%ebp),%eax
  8027ea:	89 c2                	mov    %eax,%edx
  8027ec:	c1 ea 16             	shr    $0x16,%edx
  8027ef:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8027f6:	f6 c2 01             	test   $0x1,%dl
  8027f9:	74 26                	je     802821 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  8027fb:	c1 e8 0c             	shr    $0xc,%eax
  8027fe:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802805:	a8 01                	test   $0x1,%al
  802807:	74 18                	je     802821 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  802809:	c1 e8 0c             	shr    $0xc,%eax
  80280c:	8d 14 40             	lea    (%eax,%eax,2),%edx
  80280f:	c1 e2 02             	shl    $0x2,%edx
  802812:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  802817:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  80281c:	0f b7 c0             	movzwl %ax,%eax
  80281f:	eb 05                	jmp    802826 <pageref+0x42>
  802821:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802826:	5d                   	pop    %ebp
  802827:	c3                   	ret    
	...

00802830 <__udivdi3>:
  802830:	55                   	push   %ebp
  802831:	89 e5                	mov    %esp,%ebp
  802833:	57                   	push   %edi
  802834:	56                   	push   %esi
  802835:	83 ec 10             	sub    $0x10,%esp
  802838:	8b 45 14             	mov    0x14(%ebp),%eax
  80283b:	8b 55 08             	mov    0x8(%ebp),%edx
  80283e:	8b 75 10             	mov    0x10(%ebp),%esi
  802841:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802844:	85 c0                	test   %eax,%eax
  802846:	89 55 f0             	mov    %edx,-0x10(%ebp)
  802849:	75 35                	jne    802880 <__udivdi3+0x50>
  80284b:	39 fe                	cmp    %edi,%esi
  80284d:	77 61                	ja     8028b0 <__udivdi3+0x80>
  80284f:	85 f6                	test   %esi,%esi
  802851:	75 0b                	jne    80285e <__udivdi3+0x2e>
  802853:	b8 01 00 00 00       	mov    $0x1,%eax
  802858:	31 d2                	xor    %edx,%edx
  80285a:	f7 f6                	div    %esi
  80285c:	89 c6                	mov    %eax,%esi
  80285e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802861:	31 d2                	xor    %edx,%edx
  802863:	89 f8                	mov    %edi,%eax
  802865:	f7 f6                	div    %esi
  802867:	89 c7                	mov    %eax,%edi
  802869:	89 c8                	mov    %ecx,%eax
  80286b:	f7 f6                	div    %esi
  80286d:	89 c1                	mov    %eax,%ecx
  80286f:	89 fa                	mov    %edi,%edx
  802871:	89 c8                	mov    %ecx,%eax
  802873:	83 c4 10             	add    $0x10,%esp
  802876:	5e                   	pop    %esi
  802877:	5f                   	pop    %edi
  802878:	5d                   	pop    %ebp
  802879:	c3                   	ret    
  80287a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802880:	39 f8                	cmp    %edi,%eax
  802882:	77 1c                	ja     8028a0 <__udivdi3+0x70>
  802884:	0f bd d0             	bsr    %eax,%edx
  802887:	83 f2 1f             	xor    $0x1f,%edx
  80288a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  80288d:	75 39                	jne    8028c8 <__udivdi3+0x98>
  80288f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  802892:	0f 86 a0 00 00 00    	jbe    802938 <__udivdi3+0x108>
  802898:	39 f8                	cmp    %edi,%eax
  80289a:	0f 82 98 00 00 00    	jb     802938 <__udivdi3+0x108>
  8028a0:	31 ff                	xor    %edi,%edi
  8028a2:	31 c9                	xor    %ecx,%ecx
  8028a4:	89 c8                	mov    %ecx,%eax
  8028a6:	89 fa                	mov    %edi,%edx
  8028a8:	83 c4 10             	add    $0x10,%esp
  8028ab:	5e                   	pop    %esi
  8028ac:	5f                   	pop    %edi
  8028ad:	5d                   	pop    %ebp
  8028ae:	c3                   	ret    
  8028af:	90                   	nop
  8028b0:	89 d1                	mov    %edx,%ecx
  8028b2:	89 fa                	mov    %edi,%edx
  8028b4:	89 c8                	mov    %ecx,%eax
  8028b6:	31 ff                	xor    %edi,%edi
  8028b8:	f7 f6                	div    %esi
  8028ba:	89 c1                	mov    %eax,%ecx
  8028bc:	89 fa                	mov    %edi,%edx
  8028be:	89 c8                	mov    %ecx,%eax
  8028c0:	83 c4 10             	add    $0x10,%esp
  8028c3:	5e                   	pop    %esi
  8028c4:	5f                   	pop    %edi
  8028c5:	5d                   	pop    %ebp
  8028c6:	c3                   	ret    
  8028c7:	90                   	nop
  8028c8:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8028cc:	89 f2                	mov    %esi,%edx
  8028ce:	d3 e0                	shl    %cl,%eax
  8028d0:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8028d3:	b8 20 00 00 00       	mov    $0x20,%eax
  8028d8:	2b 45 f4             	sub    -0xc(%ebp),%eax
  8028db:	89 c1                	mov    %eax,%ecx
  8028dd:	d3 ea                	shr    %cl,%edx
  8028df:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8028e3:	0b 55 ec             	or     -0x14(%ebp),%edx
  8028e6:	d3 e6                	shl    %cl,%esi
  8028e8:	89 c1                	mov    %eax,%ecx
  8028ea:	89 75 e8             	mov    %esi,-0x18(%ebp)
  8028ed:	89 fe                	mov    %edi,%esi
  8028ef:	d3 ee                	shr    %cl,%esi
  8028f1:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8028f5:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8028f8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8028fb:	d3 e7                	shl    %cl,%edi
  8028fd:	89 c1                	mov    %eax,%ecx
  8028ff:	d3 ea                	shr    %cl,%edx
  802901:	09 d7                	or     %edx,%edi
  802903:	89 f2                	mov    %esi,%edx
  802905:	89 f8                	mov    %edi,%eax
  802907:	f7 75 ec             	divl   -0x14(%ebp)
  80290a:	89 d6                	mov    %edx,%esi
  80290c:	89 c7                	mov    %eax,%edi
  80290e:	f7 65 e8             	mull   -0x18(%ebp)
  802911:	39 d6                	cmp    %edx,%esi
  802913:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802916:	72 30                	jb     802948 <__udivdi3+0x118>
  802918:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80291b:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  80291f:	d3 e2                	shl    %cl,%edx
  802921:	39 c2                	cmp    %eax,%edx
  802923:	73 05                	jae    80292a <__udivdi3+0xfa>
  802925:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  802928:	74 1e                	je     802948 <__udivdi3+0x118>
  80292a:	89 f9                	mov    %edi,%ecx
  80292c:	31 ff                	xor    %edi,%edi
  80292e:	e9 71 ff ff ff       	jmp    8028a4 <__udivdi3+0x74>
  802933:	90                   	nop
  802934:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802938:	31 ff                	xor    %edi,%edi
  80293a:	b9 01 00 00 00       	mov    $0x1,%ecx
  80293f:	e9 60 ff ff ff       	jmp    8028a4 <__udivdi3+0x74>
  802944:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802948:	8d 4f ff             	lea    -0x1(%edi),%ecx
  80294b:	31 ff                	xor    %edi,%edi
  80294d:	89 c8                	mov    %ecx,%eax
  80294f:	89 fa                	mov    %edi,%edx
  802951:	83 c4 10             	add    $0x10,%esp
  802954:	5e                   	pop    %esi
  802955:	5f                   	pop    %edi
  802956:	5d                   	pop    %ebp
  802957:	c3                   	ret    
	...

00802960 <__umoddi3>:
  802960:	55                   	push   %ebp
  802961:	89 e5                	mov    %esp,%ebp
  802963:	57                   	push   %edi
  802964:	56                   	push   %esi
  802965:	83 ec 20             	sub    $0x20,%esp
  802968:	8b 55 14             	mov    0x14(%ebp),%edx
  80296b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80296e:	8b 7d 10             	mov    0x10(%ebp),%edi
  802971:	8b 75 0c             	mov    0xc(%ebp),%esi
  802974:	85 d2                	test   %edx,%edx
  802976:	89 c8                	mov    %ecx,%eax
  802978:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  80297b:	75 13                	jne    802990 <__umoddi3+0x30>
  80297d:	39 f7                	cmp    %esi,%edi
  80297f:	76 3f                	jbe    8029c0 <__umoddi3+0x60>
  802981:	89 f2                	mov    %esi,%edx
  802983:	f7 f7                	div    %edi
  802985:	89 d0                	mov    %edx,%eax
  802987:	31 d2                	xor    %edx,%edx
  802989:	83 c4 20             	add    $0x20,%esp
  80298c:	5e                   	pop    %esi
  80298d:	5f                   	pop    %edi
  80298e:	5d                   	pop    %ebp
  80298f:	c3                   	ret    
  802990:	39 f2                	cmp    %esi,%edx
  802992:	77 4c                	ja     8029e0 <__umoddi3+0x80>
  802994:	0f bd ca             	bsr    %edx,%ecx
  802997:	83 f1 1f             	xor    $0x1f,%ecx
  80299a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  80299d:	75 51                	jne    8029f0 <__umoddi3+0x90>
  80299f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  8029a2:	0f 87 e0 00 00 00    	ja     802a88 <__umoddi3+0x128>
  8029a8:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8029ab:	29 f8                	sub    %edi,%eax
  8029ad:	19 d6                	sbb    %edx,%esi
  8029af:	89 45 f4             	mov    %eax,-0xc(%ebp)
  8029b2:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8029b5:	89 f2                	mov    %esi,%edx
  8029b7:	83 c4 20             	add    $0x20,%esp
  8029ba:	5e                   	pop    %esi
  8029bb:	5f                   	pop    %edi
  8029bc:	5d                   	pop    %ebp
  8029bd:	c3                   	ret    
  8029be:	66 90                	xchg   %ax,%ax
  8029c0:	85 ff                	test   %edi,%edi
  8029c2:	75 0b                	jne    8029cf <__umoddi3+0x6f>
  8029c4:	b8 01 00 00 00       	mov    $0x1,%eax
  8029c9:	31 d2                	xor    %edx,%edx
  8029cb:	f7 f7                	div    %edi
  8029cd:	89 c7                	mov    %eax,%edi
  8029cf:	89 f0                	mov    %esi,%eax
  8029d1:	31 d2                	xor    %edx,%edx
  8029d3:	f7 f7                	div    %edi
  8029d5:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8029d8:	f7 f7                	div    %edi
  8029da:	eb a9                	jmp    802985 <__umoddi3+0x25>
  8029dc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8029e0:	89 c8                	mov    %ecx,%eax
  8029e2:	89 f2                	mov    %esi,%edx
  8029e4:	83 c4 20             	add    $0x20,%esp
  8029e7:	5e                   	pop    %esi
  8029e8:	5f                   	pop    %edi
  8029e9:	5d                   	pop    %ebp
  8029ea:	c3                   	ret    
  8029eb:	90                   	nop
  8029ec:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8029f0:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8029f4:	d3 e2                	shl    %cl,%edx
  8029f6:	89 55 f4             	mov    %edx,-0xc(%ebp)
  8029f9:	ba 20 00 00 00       	mov    $0x20,%edx
  8029fe:	2b 55 f0             	sub    -0x10(%ebp),%edx
  802a01:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802a04:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802a08:	89 fa                	mov    %edi,%edx
  802a0a:	d3 ea                	shr    %cl,%edx
  802a0c:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802a10:	0b 55 f4             	or     -0xc(%ebp),%edx
  802a13:	d3 e7                	shl    %cl,%edi
  802a15:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802a19:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802a1c:	89 f2                	mov    %esi,%edx
  802a1e:	89 7d e8             	mov    %edi,-0x18(%ebp)
  802a21:	89 c7                	mov    %eax,%edi
  802a23:	d3 ea                	shr    %cl,%edx
  802a25:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802a29:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  802a2c:	89 c2                	mov    %eax,%edx
  802a2e:	d3 e6                	shl    %cl,%esi
  802a30:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802a34:	d3 ea                	shr    %cl,%edx
  802a36:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802a3a:	09 d6                	or     %edx,%esi
  802a3c:	89 f0                	mov    %esi,%eax
  802a3e:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  802a41:	d3 e7                	shl    %cl,%edi
  802a43:	89 f2                	mov    %esi,%edx
  802a45:	f7 75 f4             	divl   -0xc(%ebp)
  802a48:	89 d6                	mov    %edx,%esi
  802a4a:	f7 65 e8             	mull   -0x18(%ebp)
  802a4d:	39 d6                	cmp    %edx,%esi
  802a4f:	72 2b                	jb     802a7c <__umoddi3+0x11c>
  802a51:	39 c7                	cmp    %eax,%edi
  802a53:	72 23                	jb     802a78 <__umoddi3+0x118>
  802a55:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802a59:	29 c7                	sub    %eax,%edi
  802a5b:	19 d6                	sbb    %edx,%esi
  802a5d:	89 f0                	mov    %esi,%eax
  802a5f:	89 f2                	mov    %esi,%edx
  802a61:	d3 ef                	shr    %cl,%edi
  802a63:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802a67:	d3 e0                	shl    %cl,%eax
  802a69:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802a6d:	09 f8                	or     %edi,%eax
  802a6f:	d3 ea                	shr    %cl,%edx
  802a71:	83 c4 20             	add    $0x20,%esp
  802a74:	5e                   	pop    %esi
  802a75:	5f                   	pop    %edi
  802a76:	5d                   	pop    %ebp
  802a77:	c3                   	ret    
  802a78:	39 d6                	cmp    %edx,%esi
  802a7a:	75 d9                	jne    802a55 <__umoddi3+0xf5>
  802a7c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  802a7f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  802a82:	eb d1                	jmp    802a55 <__umoddi3+0xf5>
  802a84:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802a88:	39 f2                	cmp    %esi,%edx
  802a8a:	0f 82 18 ff ff ff    	jb     8029a8 <__umoddi3+0x48>
  802a90:	e9 1d ff ff ff       	jmp    8029b2 <__umoddi3+0x52>
